Replacing with VBA in columns and rows

Adar123

Board Regular
Joined
Apr 1, 2018
Messages
83
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
I am working on data transformation with about 20 parameters to be replaced. The first part of the code with range A1 was simple and in worked. However, for some reason the second part of the code when I attempt to check the whole column starting from row 2 in column A is not working. Where is the catch?

VBA Code:
Dim OriginalTextAssetName As String
Dim CorrectedTextAssetName As String

OriginalTextAssetName = Range("A1").Value
CorrectedTextAssetName = Replace(OriginalTextAssetName, "AssetName", "Commodity")

Range("A1").Value = CorrectedTextAssetName

Dim OriginalTextCorn As String
Dim CorrectedTextCorn As String
OriginalTextCorn = Range("A2:A").Value
CorrectedTextCorn = Replace(OriginalTextCorn, "AAAA", "BBBB")

Range("A2:A").Value = CorrectedTextCorn
 

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)
In case someone will be looking, I found a neat solution:
VBA Code:
Dim oRange As Range

 For Each oRange In ActiveSheet.Range("A1:A50000")
    oRange.Replace What:="Corn Future", Replacement:="CBOTCorn", MatchCase:=True
 Next
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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