Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBA Code

Posted on 2011-03-11
2
Medium Priority
?
198 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:Seamus2626
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 35110144
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
 

Author Closing Comment

by:Seamus2626
ID: 35110166
Legend!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question