G
Guest
Hi all
I would like to find out how can I add a condition to a macro so that certain embedded functional elements will run only when the condiion is met. e.g. There is a loop built into a macro, which applies only when cell Z5 = "57", "77", or "A202". Otherwise, the macro should just skip the loop and continue. The loop itself is extracted below. Could you kindly help and add on the condition? Thanks
J.C
Dim RowNdx As Lon
Dim LastRow As Lon
LastRow = ActiveSheet.Cells(Rows.Count, "Y").End(xlUp).Ro
For RowNdx = 1 To LastRo
If Cells(RowNdx, "Y").Value = "B"
And IsNumeric(Cells(RowNdx, "D").Value) The
Cells(RowNdx, "D").NumberFormat = "$#,##0
Els
Cells(RowNdx, "D").NumberFormat = "#,##0
End I
Next RowNdx
I would like to find out how can I add a condition to a macro so that certain embedded functional elements will run only when the condiion is met. e.g. There is a loop built into a macro, which applies only when cell Z5 = "57", "77", or "A202". Otherwise, the macro should just skip the loop and continue. The loop itself is extracted below. Could you kindly help and add on the condition? Thanks
J.C
Dim RowNdx As Lon
Dim LastRow As Lon
LastRow = ActiveSheet.Cells(Rows.Count, "Y").End(xlUp).Ro
For RowNdx = 1 To LastRo
If Cells(RowNdx, "Y").Value = "B"
And IsNumeric(Cells(RowNdx, "D").Value) The
Cells(RowNdx, "D").NumberFormat = "$#,##0
Els
Cells(RowNdx, "D").NumberFormat = "#,##0
End I
Next RowNdx