Having Trouble Cleaning up the Recorder Code

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
982
Office Version
  1. 2021
Platform
  1. Windows
Hello All.
I've been trying to clean up the recorder code:

VBA Code:
Sheets("HV-1").Select
    Range("A4:B4").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("HV-1 PVT").Select
    Range("T3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("HV-1").Select
    Range("G4").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Application.CutCopyMode = False
    Range("A1").Select
    Sheets("HV-1 PVT").Select
    Range("V3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

To the new code below... but having issues.
Can someone direct me what I'm doing wrong please.
Thank you

Code:
With Sheets("HV-1")
Range("A4:B4").Range(Selection, Selection.End(xlDown)).Select
.Copy
End With

With Sheets("HV-1 PVT")
Range("T3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With

With Sheets("HV-1")
Range("G4").Range(Selection, Selection.End(xlDown)).Select
.Copy
Application.CutCopyMode = False
Range("A1").Select
End With

With Sheets("HV-1 PVT")
Range("V3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I've now cleaned it up a little and seems to be working, can I do more?
Thanks for the help

VBA Code:
Sheets("HV-1").Select
Range("A4:B4").Select
Range(Selection, Selection.End(xlDown)).Copy
Sheets("HV-1 PVT").Select
Range("T3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("HV-1").Select
Range("G4").Select
Range(Selection, Selection.End(xlDown)).Copy
Range("A1").Select
Sheets("HV-1 PVT").Select
Range("V3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
 
Upvote 0
VBA Code:
    Range(Sheets("HV-1").Range("A4:B4"), Sheets("HV-1").Range("A4:B4").End(xlDown)).Copy
    Sheets("HV-1 PVT").Range("T3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Range(Sheets("HV-1").Range("G4"), Sheets("HV-1").Range("G4").End(xlDown)).Copy
    Sheets("HV-1 PVT").Range("V3").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    Application.Goto Sheets("HV-1").Range("A1")
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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