Hello,
I am trying to use VBA to fill an entire column with the value of choice if the worksheet name is right, and after the column is filled, it will proceed to the next worksheet and do the same. I am unsure
if I am writing this correctly, greatly appreciate it if anyone is able to advise or help correct the codes!
I am trying to use VBA to fill an entire column with the value of choice if the worksheet name is right, and after the column is filled, it will proceed to the next worksheet and do the same. I am unsure
if I am writing this correctly, greatly appreciate it if anyone is able to advise or help correct the codes!
VBA Code:
Private Sub Fill()
Dim WS As Worksheet
Dim i As Long
Dim r As Range
i = Range("B" & Rows.Count).End(xlUp).Row
Set r = Range("A2:A" & i)
For Each WS In ActiveWorkbook.Worksheets
If WS.Name = "Update(Pre)" Or WS.Name = "Update XB(Pre)" Then r.Value = "Update(Pre)"
If WS.Name = "Update(Breach)" Or WS.Name = "Update XB(Breach)" Then r.Value = "Update(Breach)"
If WS.Name = "Lost(Pre)" Or WS.Name = "Lost XB(Pre)" Then r.Value = "Lost(Pre)"
If WS.Name = "Lost(Breach)" Or WS.Name = "Lost XB(Breach)" Then r.Value = "Lost(Breach)"
Next WS
End Sub