Any thoughts on why the below code would not be looping through the worksheets?
I'm trying to set a column in each sheet based on what the sheet name is. It's getting stuck on the active worksheet, and ignoring the If ws.Name <> "Default"
. This is built as a module:
Sub LangID_update()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet
Dim LastCol As Integer
Dim LastRow As Integer
Dim rng As Range
Application.ScreenUpdating = False
For Each ws In wb.Worksheets
If ws.Name <> "Default" Then
LastCol = ws.Cells(1, Columns.count).End(xlToLeft).Column
LastRow = ws.Cells(Rows.count, 1).End(xlUp).Row
Set rng = Range(Cells(2, LastCol + 1), Cells(LastRow, LastCol + 1))
With rng
For Each c In Range(Cells(2, LastCol + 1), Cells(LastRow, LastCol + 1))
If ws.Name = "ARGS" Then c.Value = "ESP"
If ws.Name = "AUTS" Then c.Value = "GR"
If ws.Name = "DEUS" Then c.Value = "GR"
Next c
End With
End If
Next
Application.ScreenUpdating = True
Set wb = Nothing
Set ws = Nothing
Set rng = Nothing
End Sub