Martin_H
Board Regular
- Joined
- Aug 26, 2020
- Messages
- 190
- Office Version
- 365
- Platform
- Windows
Hi,
I am using this code to copy data from workbook_data and paste it into workbook_master (see below).
Then I filter out all unnecessary data.
Then I delete all hidden rows (the rows I filtered out in previous step).
Now, the problem is that it takes a while to complete the last step (see the code below -> 'Delete hidden rows)
Would it be possible to somehow speed up the last part?
Thank you.
I am using this code to copy data from workbook_data and paste it into workbook_master (see below).
Then I filter out all unnecessary data.
Then I delete all hidden rows (the rows I filtered out in previous step).
Now, the problem is that it takes a while to complete the last step (see the code below -> 'Delete hidden rows)
Would it be possible to somehow speed up the last part?
Thank you.
VBA Code:
'Open workbook_data
Workbooks.Open ("address")
'Copy data from workbook_data, from worksheet data
Workbooks("workbook_data.xlsx").Sheets("data").Range("A1", Range("H" & Rows.count).End(xlUp)).Copy
'Paste copied data inside workbook_master, inside worksheet master
Workbooks("workbook_master.xlsm").Sheets("master").Range("A1").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
'Close workbook_data without save
On Error Resume Next
Workbooks("workbook_data.xlsx").Close savechanges:=False
On Error GoTo 0
'Workbook_master with sheet master is now activated
'Filter the header in the range A1 based on values in the cells G4, H4 and I4 in the worksheet Sheet_X
ActiveSheet.Range("A1").AutoFilter Field:=1, Criteria1:=Array(Worksheets("Sheet_X").Range("G4").Value, Worksheets("Sheet_X").Range("H4").Value, Worksheets("Sheet_X").Range("I4").Value), Operator:=xlFilterValues
'Delete hidden rows
Dim sht As Worksheet
Dim lastrow
Set sht = ActiveSheet
lastrow = sht.UsedRange.Rows(sht.UsedRange.Rows.count).Row
For i = lastrow To 1 Step -1
If Rows(i).Hidden = True Then Rows(i).EntireRow.DELETE
Next