help its copying only visible cells

jordanburch

Active Member
Joined
Jun 10, 2016
Messages
440
Office Version
  1. 2016
Hey GUys,

This code works great but it only copies visible cells in the data. Can you help me to get all rows ?

Sub IMPORTrawdata()
Worksheets.Add().Name = "DCAS"
Dim MyFile As String
Dim erow As Long
Dim Filepath As String
Dim wb1 As Workbook, wb2 As Workbook
Dim data_wbk4 As String
Dim data_wbk2 As String

Dim fn As String
data_wbk4 = InputBox("Enter FY I.E. FY20", Default:="FY20")
data_wbk2 = InputBox("Enter month I.E. 08-MAY20", Default:="08-MAY20")
fn = Left(data_wbk2, 6)

Application.ScreenUpdating = False
Set wb1 = ThisWorkbook
Filepath = "path\" & data_wbk4 & "\" & fn & "\"
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0 And MyFile <> "suspense automation.xlsm"

erow = wb1.Sheets("table").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Set wb2 = Workbooks.Open(Filepath & MyFile)
With wb2
.Sheets("Table").Range("A2:bm3000").Copy Destination:=wb1.Worksheets("table").Cells(erow, 1)
.Close savechanges:=False
End With
MyFile = Dir
Loop
Application.ScreenUpdating = True
End Sub

Jordan
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try adding the line in red
Rich (BB code):
With wb2
    .Sheets("Table").Rows.Hidden = False
    .Sheets("Table").Range("A2:bm3000").Copy Destination:=wb1.Worksheets("table").Cells(erow, 1)
    .Close savechanges:=False
End With
 
Upvote 0
t
Try adding the line in red
Rich (BB code):
With wb2
    .Sheets("Table").Rows.Hidden = False
    .Sheets("Table").Range("A2:bm3000").Copy Destination:=wb1.Worksheets("table").Cells(erow, 1)
    .Close savechanges:=False
End With
thats seems right but its not working for whatever reason. There is a filter on one of the columns if that matters.
 
Upvote 0
OK, try it this way
VBA Code:
With wb2
    .Sheets("Table").AutoFilterMode = False  
    .Sheets("Table").Range("A2:bm3000").Copy Destination:=wb1.Worksheets("table").Cells(erow, 1)
    .Close savechanges:=False
End With

Although the Rows.Hidden = False should have done the same thing. But Excel has its Quirks.

If that does not work then try
VBA Code:
.Sheets("Table").ShowAllData

Is sheets("Table") a pivot table?
 
Last edited:
Upvote 0
OK, try it this way
VBA Code:
With wb2
    .Sheets("Table").AutoFilterMode = False 
    .Sheets("Table").Range("A2:bm3000").Copy Destination:=wb1.Worksheets("table").Cells(erow, 1)
    .Close savechanges:=False
End With

Although the Rows.Hidden = False should have done the same thing. But Excel has its Quirks.

If that does not work then try
VBA Code:
.Sheets("Table").ShowAllData

Is sheets("Table") a pivot table?
[/QUOTE

awesome the top one worked ! Thank you sir!
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
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