Clear Clipboard

JoeyGaspard

Board Regular
Joined
Jul 22, 2019
Messages
147
Hi All, I am using the code below, and it works perfectly, but it is popping up the "Clear Clipboard" message box each time and it has to be clicked for the Routine to complete, what could I use to answer this automatically and finish the routine out?

Sub Get_Data_From_File()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for your file and Import range", FileFilter:="Excel Files (*.xls*),*xls*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
'Edit Range Below
OpenBook.Sheets(1).Range("A1:I100").Copy
ThisWorkbook.Worksheets("PayDataw5").Range("A1").PasteSpecial xlPasteValues
OpenBook.Close False
End If
Application.ScreenUpdating = True
End Sub


Here is the message box I dont want the users to see:
1589302836877.png


Thanks in advance for any help!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
How about
VBA Code:
ThisWorkbook.Worksheets("PayDataw5").Range("A1").PasteSpecial xlPasteValues
Application.CutCopyMode=False
OpenBook.Close False
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
How about
VBA Code:
ThisWorkbook.Worksheets("PayDataw5").Range("A1").PasteSpecial xlPasteValues
Application.CutCopyMode=False
OpenBook.Close False
One more wuick question, this line here where I choose the destination worksheet:
ThisWorkbook.Worksheets("PayDataw5").Range("A1").PasteSpecial xlPasteValues
Can I set that to where it just copies the data to the active sheet? I have 5 of those "PayDataw" (1-5) sheets, and I would like this macro to work on whichever one is open at the time?
 
Upvote 0
Just remove
VBA Code:
ThisWorkbook.Worksheets("PayDataw5").
 
Upvote 0
It will paste the data into whatever sheet is the active sheet.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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