VBA Code HELP PLEASE

stephen.smith

Board Regular
Joined
Jul 7, 2010
Messages
119
Hi Guys
I am trying to use VBA code to find and replace a column number in a cell reference from column A to Column B, however in the cell reference $A has been used. I have tried to perform this using the code below but it doesnt work.
Code:
Sub test()
On Error Resume Next
Dim c As String, d As String
c = InputBox("A")
d = InputBox("B")
Range("A1:A100").Replace "$" & c, "$" & d
End Sub

I have also attached a picture of an example of what the cells look like and one of the cells show the exact cell reference of one of the cells I am attempting to change.
Any help would be really appreciated as this is causing me a lot of problems.
Thanks in advance
Stephen
Excel Workbook
ABCDEFG
1Column A
2Column A
3='C:\Users\Stephen\Desktop\[Test Database.xlsx]Sheet1'!$A4
4Column A
5Column A
6Column A
7Column A
8Column A
9Column A
10Column A
11Column A
12Column A
13Column A
14Column A
15Column A
16Column A
Sheet2
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi,
Have you tried the find and replace function that is apart of excel?

ie hitting ctrl + F and going to replace section
 
Upvote 0
stephen.smith,


Sample formulae before the macro:







After the macro:







Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


Code:
Sub UpdateFormulae()
' hiker95, 09/15/2011
' http://www.mrexcel.com/forum/showthread.php?t=579219
Application.DisplayAlerts = False
Range("A1:A16").Replace What:="$A", Replacement:="$B", LookAt:=xlPart, _
  SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Application.DisplayAlerts = True
End Sub


Then run the UpdateFormulae macro.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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