Este programa simples fará o truque. Isso contém dois loops:
For Each ws In ThisWorkbook.Worksheets
This is somewhat self-explanatory. This will loop through each worksheet in your workbook that contains this code.
Dentro do loop acima contém outro "sub loop":
For r = 2 To lastRow(ws, "B")
So, we already know from the previous loop that
ws
is the current worksheet in the "parent loop". r = 2 is the starting row (you can change this to r = 1 if you do NOT have any column headers).lastRow
is a function I included in the below code to automatically determine the last row in any column (in your case we are using column 2 / column B).
O código a seguir foi testado e funciona:
Option Explicit
Sub changeRows()
Dim ws As Worksheet, r As Long
For Each ws In ThisWorkbook.Worksheets
ws.Activate
For r = 2 To lastRow(ws, "B")
If ws.Cells(r, 2) = "Clear Votive Cup" Then
ws.Cells(r, "H") = 1.49
End If
Next r
Next ws
End Sub
Function lastRow(ws As Worksheet, Optional col As Variant = 1) As Long
Debug.Print ws.Name
With ws
lastRow = .Cells(.Rows.Count, col).End(xlUp).row
End With
End Function