I have an xls that has multiple worksheets and i need to run a macro that will format certain rows on each sheet. The rows are always different but the columns are all the same B-E on each sheet. The condition to look for is the word "Total", if it has that word anywhere on the row then we need the row to be formatted between Col B-E (Bold and a top line). Is there a good macro that can help us do this? Tried for a week and nothing is working.
Last edited by Aredmon25; 02-15-2012 at 08:37 AM.
Hello Aredmon25,
Welcome to the Forum!
This macro will check columns "B:E" of each sheet for any occurrence of the word "total". When found, a border is added to the top of the cells and the cells font is set to bold.
Sub FormatTotals() Dim Data As Variant Dim I As Long Dim Rng As Range Dim Text As String Dim Wks As Worksheet For Each Wks In Worksheets Set Rng = Wks.Range("B1:E" & Wks.UsedRange.Rows.Count) Data = Rng.Value For I = 1 To UBound(Data) Text = Join(WorksheetFunction.Index(Data, I, 0)) If UCase(Text) Like "*TOTAL*" Then Rng.Rows(I).Font.Bold = True With Rng.Rows(I).Borders(xlEdgeTop) .Weight = xlMedium .LineStyle = xlContinuous End With End If Next I Next Wks End Sub
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Thanks! We will give it a shot and see if it works. Thanks!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks