I am running Excel 2007 on Windows XPProfessional. I have copied and edited a macro from another program and it will work the first time I run it. When I try to run it again, it gives me a run-time error of " '1004' Microsoft Office Excel cannot insert columns because the last column (column IV) contains data. You will not get any data."
I am new to programming, no schooling, only self-taught, and am struggling through this. I think I need an If statement that looks to see if data is in place and if so to insert 16 new rows for new data populated from a tab within the workbook and data I am pulling from a SQL database. When I click on debug on the error message it takes me to this line of code within the macro:
With ActiveSheet.QueryTables.Add(server, _
Destination:=Range("B2"))
.Sql = (strSQL)
.FieldNames = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = True
.SaveData = True
End With
Anyone willing to help?
I am new to programming, no schooling, only self-taught, and am struggling through this. I think I need an If statement that looks to see if data is in place and if so to insert 16 new rows for new data populated from a tab within the workbook and data I am pulling from a SQL database. When I click on debug on the error message it takes me to this line of code within the macro:
With ActiveSheet.QueryTables.Add(server, _
Destination:=Range("B2"))
.Sql = (strSQL)
.FieldNames = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = True
.SaveData = True
End With
Anyone willing to help?