Macro find and replace for multiple sheets on just 1 column

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
471
Office Version
  1. 365
Platform
  1. Windows
I have the following macro that replaces part of a formula for only column B that works fine,
could somone adjust it so it would run for 50 sheets,
My workbook has 55 sheets, the 1st 5 sheets i would like it not to run on
The next 50 sheets are named 1,2,3,4,5,6,7 and so on
Thanks

VBA Code:
Sub find_and_replace()
    Columns("b").Replace What:="$D$1000:$D$267777", _
                            Replacement:="$D$1:$D$267777", _
                            LookAt:=xlPart, _
                            SearchOrder:=xlByRows, _
                            MatchCase:=False, _
                            SearchFormat:=False, _
                            ReplaceFormat:=False
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try this:
VBA Code:
Sub find_and_replace()
 Dim k As Long
  For k = 1 To 50
    Sheets(k).Columns("b").Replace What:="$D$1000:$D$267777", _
     Replacement:="$D$1:$D$267777", LookAt:=xlPart, _
       SearchOrder:=xlByRows, MatchCase:=False, _
         SearchFormat:=False, ReplaceFormat:=False
  Next k
End Sub
 
Upvote 0
Solution
Try this:
VBA Code:
Sub find_and_replace()
Dim k As Long
  For k = 1 To 50
    Sheets(k).Columns("b").Replace What:="$D$1000:$D$267777", _
     Replacement:="$D$1:$D$267777", LookAt:=xlPart, _
       SearchOrder:=xlByRows, MatchCase:=False, _
         SearchFormat:=False, ReplaceFormat:=False
  Next k
End Sub
Thanks alot, that works
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,141
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top