Replace with copy and paste

Hansulet

Board Regular
Joined
Jan 24, 2013
Messages
173
Office Version
  1. 2021
Platform
  1. Windows
I need a macro to replace the cells

My code is:
Selection.Replace What:="03.2018", Replacement:="04.2018", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

But instead "03.2018" should be what i copied from the cell A1 and instead "04.2018" should be what i copied from the cell A2
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
maybe
Rich (BB code):
Selection.Replace What:=Range("A1").value, Replacement:=Range("A2").value, LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
 
Last edited:
Upvote 0
Dear Fazza
Please help to edit this my code I would like to another sheet my code working but not good
please review again
Thank
Lotto beginner vba

Private Sub CommandButton1_Click()

Worksheets("3G U21").Range("A2:A100000").Select
Selection.Replace what:="U21-", replacement:=" ", lookat:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Worksheets(ActiveSheet.Index + 1).Select
Worksheets("3G U08").Range("A2:A100000").Select
Selection.Replace what:="U08-", replacement:=" ", lookat:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Worksheets(ActiveSheet.Index + 1).Select
Worksheets("4G L21").Range("A2:A100000").Select
Selection.Replace what:="L21-", replacement:=" ", lookat:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

MsgBox "DONE"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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