Hi There
I have the following macro but needed some advise on how to update it so that it only updates visible rows?
Thanks in advance!
Sub OrderPopulate()
Dim LR As Long, i As Long
Dim order As String
Dim customer As String
Dim MinCost As String
Dim MaxCost As String
Dim Key As String
order = Range("D17").Value
customer = Range("D20").Value
MinCost = Range("D21").Value
MaxCost = Range("D22").Value
Key = Range("D23").Value
LR = Range("F" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
If order <> "" And customer <> "" And Right(Range("F" & i).Value, 1) = Key Then Rows(i).EntireRow.Cells(17).Value = customer
If order <> "" And MinCost <> "" And Right(Range("F" & i).Value, 1) = Key Then Rows(i).EntireRow.Cells(19).Value = MinCost
If order <> "" And MaxiCost <> "" And Right(Range("F" & i).Value, 1) = Key Then Rows(i).EntireRow.Cells(21).Value = MaxCost
Next i
End Sub
I have the following macro but needed some advise on how to update it so that it only updates visible rows?
Thanks in advance!
Sub OrderPopulate()
Dim LR As Long, i As Long
Dim order As String
Dim customer As String
Dim MinCost As String
Dim MaxCost As String
Dim Key As String
order = Range("D17").Value
customer = Range("D20").Value
MinCost = Range("D21").Value
MaxCost = Range("D22").Value
Key = Range("D23").Value
LR = Range("F" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
If order <> "" And customer <> "" And Right(Range("F" & i).Value, 1) = Key Then Rows(i).EntireRow.Cells(17).Value = customer
If order <> "" And MinCost <> "" And Right(Range("F" & i).Value, 1) = Key Then Rows(i).EntireRow.Cells(19).Value = MinCost
If order <> "" And MaxiCost <> "" And Right(Range("F" & i).Value, 1) = Key Then Rows(i).EntireRow.Cells(21).Value = MaxCost
Next i
End Sub