stephen.smith
Board Regular
- Joined
- Jul 7, 2010
- Messages
- 119
Hey guys
I am trying to change a cell reference using VBA. The reference has the column with $ before hand so, $B and I am trying to use code to change this to any other column example $K on many different cells at one time. I have tried a replace code but its not working because of the $ I think. I need to keep the $ in the reference, so is there a way to do this. Any help would be really appreciated. Below is an example of what i have tried.
Thanks
Stephen
Code:
Sub test()
On Error Resume Next
Dim c As String, d As String
c = InputBox("Enter Original Column Letter")
d = InputBox("Enter New Column Letter")
Range("A1:A100").Replace "$" & c, "$" & d
End Sub
I am trying to change a cell reference using VBA. The reference has the column with $ before hand so, $B and I am trying to use code to change this to any other column example $K on many different cells at one time. I have tried a replace code but its not working because of the $ I think. I need to keep the $ in the reference, so is there a way to do this. Any help would be really appreciated. Below is an example of what i have tried.
Thanks
Stephen
Code:
Sub test()
On Error Resume Next
Dim c As String, d As String
c = InputBox("Enter Original Column Letter")
d = InputBox("Enter New Column Letter")
Range("A1:A100").Replace "$" & c, "$" & d
End Sub