Find and replace using array - need to alter it

lYoung

New Member
Joined
Mar 1, 2020
Messages
35
Office Version
  1. 365
Platform
  1. Windows
'this is not my code, however I would like to use it but I am not searching multiple sheets only 1. How can I tweak the code but use it on only one sheet? I've tried many variations with no luck - help would be greatly appreciated:)

Dim fndList As Integer
Dim rplcList As Integer
Dim tbl As ListObject
Dim myArray As Variant


'Create variable to point to your table
Set tbl = Worksheets("Sheet1").ListObjects("Table1")


'Create an Array out of the Table's Data
Set TempArray = tbl.DataBodyRange
myArray = Application.Transpose(TempArray)

'Designate Columns for Find/Replace data
fndList = 1
rplcList = 2


'Loop through each item in Array lists
For x = LBound(myArray, 1) To UBound(myArray, 2)
'Loop through each worksheet in ActiveWorkbook (skip sheet with table in it)
For Each sht In ActiveWorkbook.Worksheets
If sht.Name <> tbl.Parent.Name Then

sht.Cells.Replace What:=myArray(fndList, x), Replacement:=myArray(rplcList, x), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False

End If
Next sht
Next x


End Sub
 
Sorry, I sent you the wrong column, that is why it was showing as D. Here is the correct range(column W)
JCReport_v1.xlsm
U
1Cost Code
2APP:SUBCONTRACT
3APPLIANCES
4APPLIANCES
5CAB:MATERIAL
6CAB:MATERIAL
7CAB:MATERIAL
8CAB:MATERIAL
9CAB:MATERIAL
10CAB:MATERIAL
11CAB:SUBCONTRACT
12CAB:SUBCONTRACT
13CABINETRY
14CABINETRY
15CABINETRY
16CLEANING
17CLEANING
18CON:GENERAL
19CON:SUBCONTRACT
20CONT: PACKING,HANDLNG,STORAGE
21CONT: PACKING,HANDLNG,STORAGE
22CONT: PACKING,HANDLNG,STORAGE
23CONTENT MANIPULATION
24CONTENT MANIPULATION
25CONTENT MANIPULATION
26DOORS
27DOORS
28DOORS
29DRY:MATERIAL
30DRY:MATERIAL
31DRY:MATERIAL
32DRY:SUBCONTRACT
33DRY:SUBCONTRACT
34DRYWALL
35DRYWALL
36DRYWALL
37DRYWALL
38ELE:MATERIAL
39ELE:SUBCONTRACT
40ELE:SUBCONTRACT
41ELECTRICAL
42ELECTRICAL
43FCC:LABOR
44FCC:MATERIAL
45FCC:MATERIAL
46FCC:SUBCONTRACT
47FCC:SUBCONTRACT
48FCC:SUBCONTRACT
49FCS:SUBCONTRACT
50FCT:SUBCONTRACT
51FCV:MATERIAL
52FCV:MATERIAL
53FCV:MATERIAL
54FCV:SUBCONTRACT
55FCW:SUBCONTRACT
56FINISH CARPENTRY / TRIMWORK
57FINISH CARPENTRY / TRIMWORK
58FINISH CARPENTRY / TRIMWORK
59FLOOR COVERING - CARPET
60FLOOR COVERING - CARPET
61FLOOR COVERING - CARPET
62FLOOR COVERING - CARPET
63FLOOR COVERING - CARPET
64FLOOR COVERING - CERAMIC TILE
65FLOOR COVERING - CERAMIC TILE
66FLOOR COVERING - CERAMIC TILE
67FLOOR COVERING - STONE
68FLOOR COVERING - STONE
69FLOOR COVERING - STONE
70FLOOR COVERING - VINYL
71FLOOR COVERING - VINYL
72FLOOR COVERING - VINYL
73FLOOR COVERING - VINYL
74FNC:MATERIAL
75FNC:SUBCONTRACT
76FRAMING & ROUGH CARPENTRY
77FRAMING & ROUGH CARPENTRY
78FRAMING & ROUGH CARPENTRY
79FRM:SUBCONTRACT
80GENERAL DEMOLITION
81GENERAL DEMOLITION
82GENERAL DEMOLITION
83HAZARDOUS MATERIAL REMEDIATION
84HAZARDOUS MATERIAL REMEDIATION
85HAZARDOUS MATERIAL REMEDIATION
86HAZARDOUS MATERIAL REMEDIATION
87HAZARDOUS MATERIAL REMEDIATION
88HEAT, VENT & AIR CONDITIONING
89HEAT, VENT & AIR CONDITIONING
90HMR:SUBCONTRACT
91HVC:SUBCONTRACT
92LIGHT FIXTURES
93LIGHT FIXTURES
94LIT:SUBCONTRACT
95Material Sales Tax
96MIRRORS & SHOWER DOORS
97MIRRORS & SHOWER DOORS
98MSD:SUBCONTRACT
99Overhead
100PAINTING
101PAINTING
102PAINTING
103PAINTING
104PLM:MATERIAL
105PLM:MATERIAL
106PLM:MATERIAL
107PLM:SUBCONTRACT
108PLUMBING
109PLUMBING
110PLUMBING
111PLUMBING
112PNT:MATERIAL
113PNT:MATERIAL
114PNT:SUBCONTRACT
115PNT:SUBCONTRACT
116Profit
117Storage Rental Tax
118TIL:MATERIAL
119TIL:MATERIAL
120TIL:SUBCONTRACT
121TILE
122TILE
123TILE
124TILE
125WATER EXTRACTION & REMEDIATION
126WATER EXTRACTION & REMEDIATION
127WATER EXTRACTION & REMEDIATION
128WATER EXTRACTION & REMEDIATION
129WDT:SUBCONTRACT
130WINDOW TREATMENT
131WINDOW TREATMENT
132WTR:LABOR
133WTR:LABOR
134WTR:MATERIAL
Data
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
With that data (which appears to be col U) I get

+Fluff.xlsm
W
1Cost Code
2APP:SUBCONTRACT
3APP
4APP
5CAB:MATERIAL
6CAB:MATERIAL
7CAB:MATERIAL
8CAB:MATERIAL
9CAB:MATERIAL
10CAB:MATERIAL
11CAB:SUBCONTRACT
12CAB:SUBCONTRACT
13CAB
14CAB
15CAB
16CLN
17CLN
18CON:GENERAL
19CON
20CON
21CON
22CON
23CON
24CON
25CON
26DOR
27DOR
28DOR
29DRY:MATERIAL
30DRY:MATERIAL
31DRY:MATERIAL
32DRY:SUBCONTRACT
33DRY:SUBCONTRACT
34DRY
35DRY
36DRY
37DRY
38ELE:MATERIAL
39ELE:SUBCONTRACT
40ELE:SUBCONTRACT
41ELE
42ELE
43FCC:LABOR
44FCC:MATERIAL
45FCC:MATERIAL
46FCC:SUBCONTRACT
47FCC:SUBCONTRACT
48FCC:SUBCONTRACT
49FCS:SUBCONTRACT
50FCT:SUBCONTRACT
51FCV:MATERIAL
52FCV:MATERIAL
53FCV:MATERIAL
54FCV:SUBCONTRACT
55FCW:SUBCONTRACT
56FNC
57FNC
58FNC
59FCC
60FCC
61FCC
62FCC
63FCC
64FCT
65FCT
66FCT
67FCR
68FCR
69FCR
70FCV
71FCV
72FCV
73FCV
74FNC:MATERIAL
75FNC:SUBCONTRACT
76FRM
77FRM
78FRM
79FRM:SUBCONTRACT
80DMO
81DMO
82DMO
83HMR
84HMR
85HMR
86HMR
87HMR
88HVC
89HVC
90HMR:SUBCONTRACT
91HVC:SUBCONTRACT
92LIT
93LIT
94LIT:SUBCONTRACT
95Material Sales Tax
96MIRRORS & SHOWER DOR
97MIRRORS & SHOWER DOR
98MSD:SUBCONTRACT
99Overhead
100PNT
101PNT
102PNT
103PNT
104PLM:MATERIAL
105PLM:MATERIAL
106PLM:MATERIAL
107PLM:SUBCONTRACT
108PLM
109PLM
110PLM
111PLM
112PNT:MATERIAL
113PNT:MATERIAL
114PNT:SUBCONTRACT
115PNT:SUBCONTRACT
116Profit
117Storage Rental Tax
118TIL:MATERIAL
119TIL:MATERIAL
120TIL:SUBCONTRACT
121TIL
122TIL
123TIL
124TIL
125WTR
126WTR
127WTR
128WTR
129WDT:SUBCONTRACT
130WDT
131WDT
132WTR:LABOR
133WTR:LABOR
134WTR:MATERIAL
Sheet2
 
Upvote 0
Yes I am. Can you share the file?
If so upload it to a share site such as OneDrive, DropBox, mark for sharing & post the link you get to the thread.
 
Upvote 0
I'm using OneDrive, need an email address to send a link to the file
 
Upvote 0
Right click the file, select share, then click copy link & it will give you a link, click Copy & then paste the link to the thread
 
Upvote 0
uploading a different file. I gave you only the data worksheet, not the other sheets. Take just a moment
 
Upvote 0
Ok, thanks for that, are you trying to run this on column W or col U?
It looks as though it should be co U
 
Upvote 0

Forum statistics

Threads
1,215,062
Messages
6,122,925
Members
449,094
Latest member
teemeren

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