I currently have the following code that loops thru a hard coded range of rows, looking for a sub-total formula that meets my criteria. Once I find a cell that meets that I change the cells color and border.
Is there a way that I can set this dynamically instead of hard coding the range of rows?
I’m running this code from Access to format my excel sheet.
I want to replace
Is there a way that I can set this dynamically instead of hard coding the range of rows?
I’m running this code from Access to format my excel sheet.
Code:
For intJ = 2 To 2000
For Each strJ In Array("H")
If Left(xlsWorksheet.Range(strJ & intJ).Formula, 9) = "=SUBTOTAL" Then
xlsWorksheet.Rows(intJ).Font.Bold = True
For Each strCol In Array("H")
xlsWorksheet.Range(strCol & intJ).Interior.ColorIndex = 44
xlsWorksheet.Range(strCol & intJ).Borders(xlEdgeLeft).LineStyle = xlContinuous
xlsWorksheet.Range(strCol & intJ).Font.Bold = True
xlsWorksheet.Range(strCol & intJ).Borders(xlEdgeRight).LineStyle = xlContinuous
xlsWorksheet.Range(strCol & intJ).Borders(xlEdgeTop).LineStyle = xlContinuous
xlsWorksheet.Range(strCol & intJ).Borders(xlEdgeBottom).LineStyle = xlContinuous
Next strCol
End If
Next strJ
Next intJ
I want to replace
Code:
For intJ = 2 To 2000