Having Trouble Cleaning up the Recorder Code

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
946
Office Version
  1. 2016
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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
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,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

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