samilynn
Board Regular
- Joined
- Jun 24, 2003
- Messages
- 166
- Office Version
- 2016
- Platform
- Windows
Hi, any suggestions on how I can change this code to only work in the Active Sheet?
It currently makes the changes in all the sheets in the Workbook.
Thanks,
Samantha
Option Explicit
Sub ReplaceNames()
Dim sht As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each sht In Worksheets
sht.Cells.Replace What:="ABC1", replacement:="AAAAAAAAAA", Lookat:=xlPart, MatchCase:=False
sht.Cells.Replace What:="XYZ1", replacement:="XXXXXXXXX", Lookat:=xlPart, MatchCase:=False
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
It currently makes the changes in all the sheets in the Workbook.
Thanks,
Samantha
Option Explicit
Sub ReplaceNames()
Dim sht As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each sht In Worksheets
sht.Cells.Replace What:="ABC1", replacement:="AAAAAAAAAA", Lookat:=xlPart, MatchCase:=False
sht.Cells.Replace What:="XYZ1", replacement:="XXXXXXXXX", Lookat:=xlPart, MatchCase:=False
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub