Hello,
I have a VBA script that works in a workbook, but it will not work if I try to run from personal.xslb
What am I doing wrong?
Also, is there a better way to write the code?
I have a VBA script that works in a workbook, but it will not work if I try to run from personal.xslb
What am I doing wrong?
Also, is there a better way to write the code?
VBA Code:
Sub Test()
Dim ws As Worksheet
Dim row As Long
Set ws = Sheet1
For row = 1 To Cells(ws.Rows.Count, "A").End(xlUp).row
If StrComp(Cells(row, 1).Value, "02455", vbTextCompare) = 0 Then
Cells(row, 2).Value = Cells(row, 2).Value / 20
End If
Next row
For row = 1 To Cells(ws.Rows.Count, "A").End(xlUp).row
If StrComp(Cells(row, 1).Value, "06733", vbTextCompare) = 0 Then
Cells(row, 2).Value = Cells(row, 2).Value / 10
End If
Next row
For row = 1 To Cells(ws.Rows.Count, "A").End(xlUp).row
If StrComp(Cells(row, 1).Value, "011255", vbTextCompare) = 0 Then
Cells(row, 2).Value = Cells(row, 2).Value / 50
End If
Next row
End Sub