Macro to select columns and replace data
Try the below..Adjust the to column to suit your requirement....
Sub Macro()
Dim lngCol As Long, strCol As String
For lngCol = Columns("AQ").Column To Columns("BB").Column
strCol = Split(Columns(lngCol).Address(False, False), ":")(0)
Columns(strCol).Replace What:=" ap$", Replacement:=strCol & "$", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Next
End Sub
If this post helps click Yes
---------------
Jacob Skaria
"graemeh" wrote:
Ron, I need it to step from column to column and do a replacement for each
coulmn as it goes. Currently I have 37 columns that I need to step do a
replacement command.
"Ron" wrote:
On Jul 8, 4:14 pm, graemeh wrote:
I want to loop through a range of colums and do a replacement like below. Is
there an easy way to do this via a marco?
Columns("AQ:AQ").Select
Selection.Replace What:="ap$", Replacement:="AQ$", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Columns("AR:AR").Select
Selection.Replace What:="ap$", Replacement:="Ar$", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
This should work for you.
Columns("AQ").Replace What:=" ap$", Replacement:="AQ$",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
|