Two Problems 1. keep getting a clear clipboard message 2. wont close workbook completely

Summerso1

New Member
Joined
Jul 24, 2014
Messages
45
Hi,

I have to code below which works but there are two things that I need it to do.

1. at the point of paste don't ask if I was to clear the clipboard
2. completely close the Email_Report after its finished

Code:
Sub copy()

Sheets("DATA").Select




Dim wb1 As Workbook
Dim wb2 As Workbook


Set wb1 = Workbooks("Email Tool.xlsm")
Dim objApp As Excel.Application
Set objApp = CreateObject("Excel.Application")
objApp.Visible = True
Set wb2 = objApp.Workbooks.Open("H:\Online\Email\Reporting\Email_Report.xls")




wb2.Sheets("email_report").Range("C:M").copy




wb1.Sheets("DATA").Range("A1").Select


wb1.Sheets("DATA").Paste
Application.CutCopyMode = False


Range("A1:K9").Select
    Selection.Delete Shift:=xlUp


wb2.Close SaveChanges:=False


Set wb2 = Nothing
Set objApp = Nothing
 
Try this code (on a copy of your work first)...
Code:
Sub Copy()

    Dim wb1 As Workbook, wb2 As Workbook
    
    Set wb1 = ThisWorkbook ' I'm guessing Workbooks("Email Tool.xlsm") is the one with the code in.
    Set wb2 = Workbooks.Open("H:\Online\Email\Reporting\Email_Report.xls")
    
    wb2.Sheets("email_report").Range("C:M").Copy Destination:=wb1.Sheets("Data").Range("A1")
    wb1.Sheets("Data").Range("A1:K9").Delete Shift:=xlUp 'This is deleting some of the data you've just pasted in???
    
    wb2.Close Savechanges:=False


End Sub
 
Upvote 0

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