PDA

View Full Version : looping through columns and rows



rgr
04-11-2006, 05:43 PM
I have a spreadsheet with 50 columns that are each separated by a blank column, i.e; every other column. In each column I have anywhere from 0 to 70 rows of data. I would like to format the data bold with a background and set a border on only those cells with data. There are no empty cells between rows of data. The data starts in C11. I would like either a command button and/or a key sequence to initiate the procedure. Is this do-able?

jindon
04-11-2006, 06:02 PM
Sub test()
Dim r As Range, ff As String
With Sheets("sheet1") ' <- alter to suite
Set r = .Rows(11).Find("*", , , xlPart)
If Not r Is Nothing Then
ff = r.Address
Do
With .Range(r, r.End(xlDown))
.Font.Bold = True
.Borders.Weight = xlThin
End With
Set r = .Rows(11).FindNext(r)
Loop Until ff = r.Address
End If
End With
End Sub

rgr
04-11-2006, 06:57 PM
This is great, thank you very much, I've never seen code quite like this.