Dnyan
Board Regular
- Joined
- Mar 25, 2010
- Messages
- 90
Hi,
I am using below code for consolidate multiple workbook, however I want to consolidate data from Sheet1 which is protected. so is it possible to consolidate data from Protected sheet.
The error is coming while running the code.(Run-time error '1004')
Kindly suggest
I am using below code for consolidate multiple workbook, however I want to consolidate data from Sheet1 which is protected. so is it possible to consolidate data from Protected sheet.
HTML:
Option ExplicitDim fsoMain As New FileSystemObjectDim myFldr As FolderDim myWB As Workbook, tempWB As WorkbookDim fl As File
Sub getFiles()
'Always Change Below path as required, this will consolidate data from your folder of below given path Set myFldr = fsoMain.GetFolder("S:\Mumbai Shared\Mumbai Sales and service\Process\Mumbai Motor paper\Others\Login Tracker") Set myWB = ActiveWorkbook For Each fl In myFldr.Files If Right(fl.Name, 4) = "xlsm" Then '2007 format and above Set tempWB = Workbooks.Open(fl.Path) 'opening the files one by one With Sheets("Sheet1") .Range("A2").CurrentRegion.Offset(1).SpecialCells(xlVisible).Copy myWB.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1) End With tempWB.Close False End If Next fl Application.ScreenUpdating = TrueEnd Sub
The error is coming while running the code.(Run-time error '1004')
Kindly suggest