0

Good day,

I'm looking for assistance in figuring out my problem. I wanted to find a cell in Column A that contains the text "Grand Total". Find is the keyword since it may sometimes entered in A14, or A12, or A20. When the text is found, I wanted to select that cell, and the next cell in column B. Let's say the text is found in A14, then select A14 and B14.

In that way, I would like to continue and edit the format as font = bold, fill color, and font color (I will figure it out soon).

I can't seem to find a code that will help me so I appreciate any help. Below is a code I found but it seems to be not working FOR ME. Credits for this code from this link: How to select a range of rows using two variables in VBA

Dim Consultant1 As Integer, Consultant2 As Integer
Dim ConsultantRange As Range

Dim rngFind As Range
Set rngFind = Columns("A:A").Find(What:="Grand Total", After:=Range("A1"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)

If Not rngFind Is Nothing Then
    Consultant1 = rngFind.row + 1
End If

Set rngFind = Columns("A:A").Find(What:="Grand Total", After:=Range("A1"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)

If Not rngFind Is Nothing Then
    Consultant2 = rngFind.row - 1
End If

If Consultant1 > 0 And Consultant2 > 0 Then
    Set ConsultantRange = Range(Cells(Consultant1, 2), Cells(Consultant2, 2))
    With ConsultantRange.Selection.Font.Bold = True
    End With
End If

1 Answer 1

2

How about:

Sub qwerty()
    Dim rngFind As Range
    Set rngFind = Range("A:A").Find(What:="Grand Total", After:=Range("A1"))
    rngFind.Resize(1, 2).Select
End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

Oh my so 'Resize' is the code I'm particularly looking for. This is great! Thank you Gary's Student!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.