VBA Code

Hi,

I have attached a spreadsheet where i need some code to do two things

(1) Loop and find Grand total (never further than 500 rows, so can loop to A500
(2) Once found, make the next row size 6 with white fill (like in file) and the next 20 rows after that, filled with black

Thanks
Seamus
test1.xls
Seamus2626Asked:
Who is Participating?
 
Rory ArchibaldCommented:
Try this:
Sub FormatIt()
   Dim rngFound As Range
   Set rngFound = Range("A:A").Find(what:="Grand total", LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
   If Not rngFound Is Nothing Then
      With rngFound
         With .Offset(1).Resize(, 7)
            .RowHeight = 6
            .Interior.Color = vbWhite
         End With
         With .Offset(2).Resize(20).EntireRow
            .Interior.Color = vbBlack
         End With
      End With
   End If
End Sub

Open in new window

0
 
Seamus2626Author Commented:
Legend!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.