peterhui50
New Member
- Joined
- Nov 4, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi,
I'm trying to create a macro that will replace all the "1"s in a column with a value in Range "A1", then move onto column 2 and replace it with the value in Range "B1" and so on.
this is what I have so far
As you can see, it requires the user to put the column number and the location of the value, it works but just not efficient at all.
I"m looking to just loop through a range of columns and the value of it's replacement will move along with it.
Any help is very much appreciated, I have several hundred of these columns and tried to do this in PQ but it gives another problem.
I'm trying to create a macro that will replace all the "1"s in a column with a value in Range "A1", then move onto column 2 and replace it with the value in Range "B1" and so on.
this is what I have so far
Code:
Sub Macro2()
'
' Macro2 Macro
Dim X As Integer
X = InputBox("What column number?")
Y = InputBox("Where is the value?")
Worksheets("Sheet1").Columns(X).Replace _
What:=1, Replacement:=Range(Y).Value, _
SearchOrder:=xlByColumns, MatchCase:=True
End Sub
As you can see, it requires the user to put the column number and the location of the value, it works but just not efficient at all.
I"m looking to just loop through a range of columns and the value of it's replacement will move along with it.
Any help is very much appreciated, I have several hundred of these columns and tried to do this in PQ but it gives another problem.