Reputation: 23
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
Upvotes: 0
Views: 3833
Reputation: 96791
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
Upvotes: 2