Hi Community;
First of all I want to introduce myself, my name is Euro and I'm a Macro programmer beginner, having said that I want to thank all the forum community for the amazing amount of information that it is available here, even if this is my first post I ve been browsing the forums for knowledge for some days now.
Having said that, let s go to the point. This is the first Macro that I'm writing, and what it does is basically downloads data from the internet and arranges it in the appropiate format to create a Pivot Table from the database. I'm pretty satisfied with its performance, but I want to remove the annoying alert when it closes the workbook "Do you Want to save?" etc. In order to not have to be clicking the alerts while it downloads. However, when I add the Application.DisplayAlert = False into my code, the macro fails to copy the information to the database spreadsheet. The error is "1004 Microsoft Excel Cannot paste the data" (On the Underlined + Bold Statement below).
My Code :
Sub DataHooper()
Application.DisplayAlerts = False
Worksheets("DataBase").Select
Range("A2").Select
Do While ActiveCell.Value <> Empty
ActiveCell.Offset(1, 0).Select
Loop
Worksheets("Input Table").Select
Range("B6").Select
Do While ActiveCell.Value <> Empty
ActiveCell.Offset(0, 8).Select
MyLink = ActiveCell
Workbooks.Open Filename:=MyLink
Windows("table.csv").Visible = True
Columns("B:E").Select
Selection.Delete Shift:=xlToLeft
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("A2:C2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveWindow.Close
Worksheets("DataBase").Select
ActiveCell.Select
ActiveSheet.Paste
Worksheets("Input Table").Select
ActiveCell.Offset(0, -8).Select
Selection.Copy
Worksheets("Database").Select
ActiveCell.Select
Dim NumberRows As Integer
Range(Selection, Selection.End(xlDown)).Select
NumberRows = Selection.Rows.Count
ActiveCell.Offset(0, 1).Select
ActiveCell.Resize(NumberRows, 1).Select
ActiveSheet.Paste
ActiveCell.Offset(0, -1).Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Worksheets("Input Table").Select
ActiveCell.Offset(1, 0).Select
Loop
Application.CutCopyMode = False
Application.DisplayAlerts = True
End Sub
Bookmarks