VBA Code Editing Help Requested

Justinian

Well-known Member
Joined
Aug 9, 2009
Messages
1,557
Office Version
  1. 365
Platform
  1. Windows
Every morning, I copy data from an external source and paste into Excel. This gives me work order information from the previous day except for one problem: I do not need the pasted data in column G. Starting from a blank worksheet, I run this code to paste the data:

Sub Paste_Copied_Data()

Range("A1").Select
ActiveSheet.paste
Range("L18").Select

End Sub


When I then try to remove the pasted data in column G with the following macro, all my data gets deleted instead of just column G:

Sub Macro1()
'
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft

End Sub

How do I paste my data and then have the code delete column G without deleting anything else? What am I doing wrong?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
you could try:
Rich (BB code):
Rich (BB code):

Sub Macro1()
Columns("G:G").Select
Selection.clearcontents
End Sub
 
Upvote 0
How do I combine the code to paste and delete column G in one macro?
 
Upvote 0
Anyone? I feel like this is s simple solution but I cannot figure it out.
 
Upvote 0
Do you have any merged cells?
 
Upvote 0
Any other macros, especially event code?
 
Upvote 0
Yes, I have four total buttons each assigned a macro.

- Button 1 pastes copied data from an external database
- Button 2 removes unwanted names from the report
- Button 3 Formats the data by removing a few unwanted columns and adding front colors
- Button 4 e-mails the workbook to my recipients

Would it be easier if I posted the workbook?
 
Upvote 0
How do I combine the code to paste and delete column G in one macro?
Use the CALL procedure

Code:
SUB Cpy_Pste()
CALL  ModuleName.Paste_Copied_Data
CALL ModuleName.[COLOR=#333333]Macro1[/COLOR]
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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