I am trying to do my 1st macro ever and my spreadsheet will have varying number of lines each time. I can get the macro to work but it runs for the number of lines (16) when I recorded the macro instead of the number of lines actually in the new version of the spreadsheet now 31 rows. I have read about Do loops but do not understand how to write it.
Can anyone help me with the macro so that the number of lines is variable?
Here is my macro logic
Sub MacroTest3()
'
' MacroTest3 Macro
'
'
Range("D2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]*RC[-1]"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D16")
Range("D2:D16").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="=3.53"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Can anyone help me with the macro so that the number of lines is variable?
Here is my macro logic
Sub MacroTest3()
'
' MacroTest3 Macro
'
'
Range("D2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]*RC[-1]"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D16")
Range("D2:D16").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="=3.53"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Last edited: