Hi everyone.
I currently am using the code below, which extracts data from several excel sheets into one database.
Sub ExtractInfo()
Dim fileToOpen, n&: Application.ScreenUpdating = False
Dim wsh As Worksheet: Set wsh = ActiveSheet ' the consolidation spreadsheet
fileToOpen = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", , , , True) ' obtain the path and filename
For n = 1 To UBound(fileToOpen) ' the main loop to open all files and extract data
With Workbooks.Open(fileToOpen(n))
With .Sheets("Input File")
'now go to the consolidation spreadsheet'enter the values'to start on "A4" and then skip to next row with next file
wsh.Range("A3:I3").Offset(n).Value = WorksheetFunction.Transpose(.Range("C4:C12").Value)
wsh.Range("J3:K3").Offset(n).Value = WorksheetFunction.Transpose(.Range("C16:C17").Value)
wsh.Range("L3:R3").Offset(n).Value = WorksheetFunction.Transpose(.Range("F4:F10").Value)
wsh.Range("S3:AD3").Offset(n).Value = WorksheetFunction.Transpose(.Range("C23:C34").Value)
End With
.Close 0
End With
Next n 'go and start the process over again with the next spreadsheet
Application.ScreenUpdating = True
End Sub
Within this macro, i would like the line of code below to cause those cells which are hidden to show up as "0" if possible.
wsh.Range("S3:AD3").Offset(n).Value = WorksheetFunction.Transpose(.Range("C23:C34").Value)
For example, if the data is only from "C23 to C28" then the rest will appear as 0 on the database .
Bookmarks