created Table now vba code does not work anymore

Sjon1974

New Member
Joined
Apr 1, 2020
Messages
38
Office Version
  1. 365
Platform
  1. Windows
All,

I changed a worksheet into a table, but my import code does not work anymore.

VBA Code:
Sub Import()
   Dim ws1 As Worksheet, ws2 As Worksheet
   Dim LastRow As Long
   Dim Cl As Range
    Set ws1 = ThisWorkbook.Sheets("Import")
   Set ws2 = ThisWorkbook.Sheets("Database")
   LastRow = ws2.Cells(Rows.Count, "A").End(xlUp).Row
   ws1.Range("A7").AutoFilter 1, "*"
   ws1.AutoFilter.Range.Offset(1).EntireRow.Copy ws2.Range("a" & LastRow + 1)
   ws1.AutoFilterMode = False
   Call deleteBlankRows
   End Sub

Sub deleteBlankRows()
   Dim ws1 As Worksheet, ws2 As Worksheet
   Dim LastRow As Long
   Dim Cl As Range
   Set ws2 = ThisWorkbook.Sheets("Database")
Application.ScreenUpdating = False
ws2.Columns("G:G").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Application.ScreenUpdating = True
End Sub

I am refering to WS2 "Database" when i changed into a Table the macro is not working anymore.

What is going wrong:

Excel completly freezes and at the end is creating a 1004 error, so i have to change the range or something
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
It's possibly deleting the blanks that is causing it, if you filter the blanks before copying then you wouldn't have that problem.

Better to copy only the columns that you need as well, not the entire row, otherwise you're creating blank columns that need deleting as well.
 
Upvote 0
Yup that was it, i need an extra script for when i do multiple periods importing. But this was a single period

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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