|
A common way to work with an Excel cell relative to another cell in Microsoft Excel is to use the Offset property. In the following example, the contents of the Excel cell that's in the same row and two columns over from the active cell on the active Excel worksheet are formatted as double-underlined. Sub UnderlineDouble() ActiveCell.Offset(0, 2).Font.Underline = xlDouble End Sub Try this out! To loop through a range of Excel cells, use a variable with the Cells property in a loop in Excel. The following example fills the first 20 Excel cells in the third column with values between 5 and 100, incremented by 5. The variable counter is used as the row index for the Cells property. Sub CycleThrough() Dim counter As Integer For counter = 1 To 20 Worksheets("Sheet1").Cells(counter, 3).Value = counter * 5 Next counter End Sub The following Excel training video highlights how the macro works and double-underlines an Excel cell in a spreadsheet! |
![]()
Custom Search
|