Malak
03-29-2020, 07:23 AM
Hello,
is it possible to write the three lines in one line without listing all the offsets, but using one range to describe the three offsets?
Basically I am looking for a way to offset a range of cells like cells(-2, -2), cells(-1, -2)cells(-0, -2) from a base cell.
Malak
Sub RangeOffset()
Dim strBaseCell As String
strBaseCell = "D10"
Cells.Interior.ColorIndex = xlColorIndexNone
Range(strBaseCell).Offset(-2, -2).Cells.Interior.ColorIndex = 41
Range(strBaseCell).Offset(-1, -2).Cells.Interior.ColorIndex = 41
Range(strBaseCell).Offset(0, -2).Cells.Interior.ColorIndex = 41
End Sub
is it possible to write the three lines in one line without listing all the offsets, but using one range to describe the three offsets?
Basically I am looking for a way to offset a range of cells like cells(-2, -2), cells(-1, -2)cells(-0, -2) from a base cell.
Malak
Sub RangeOffset()
Dim strBaseCell As String
strBaseCell = "D10"
Cells.Interior.ColorIndex = xlColorIndexNone
Range(strBaseCell).Offset(-2, -2).Cells.Interior.ColorIndex = 41
Range(strBaseCell).Offset(-1, -2).Cells.Interior.ColorIndex = 41
Range(strBaseCell).Offset(0, -2).Cells.Interior.ColorIndex = 41
End Sub