Solved

VBA Code

Posted on 2011-03-11
2
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 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

Independent Software Vendors: 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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

734 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