harveyldj93
New Member
- Joined
- Aug 23, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
I am trying to write a Macro which will correct all the worksheets that contain the phrase Perm, this has a number first i.e 0000 Perm.
The code I have written is below, however it only seems to amend the first tab. Does anyone know why it isn't cycling through?
If ws.Name Like "*Perm" Then
For Each ws In ActiveWorkbook.Worksheets
If ws.Name Like "*Perm" Then
ActiveSheet.Unprotect "****"
Range("M261:M269").Select
Selection.Replace What:="T", Replacement:="U", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
ActiveSheet.Protect "****"
End If
Next ws
End Sub
Appreciate it!
The code I have written is below, however it only seems to amend the first tab. Does anyone know why it isn't cycling through?
If ws.Name Like "*Perm" Then
For Each ws In ActiveWorkbook.Worksheets
If ws.Name Like "*Perm" Then
ActiveSheet.Unprotect "****"
Range("M261:M269").Select
Selection.Replace What:="T", Replacement:="U", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
ActiveSheet.Protect "****"
End If
Next ws
End Sub
Appreciate it!