i have this code which can pull the data . i have 7 sheets. loop through all the sheets and copy the data if the condition is fulfilled.
but i can copy only data of one sheet.
i dont know where i have made a mistake. so i would be very grateful if someone could help me to look into this code and point me into right direction.
thank you very much.
but i can copy only data of one sheet.
i dont know where i have made a mistake. so i would be very grateful if someone could help me to look into this code and point me into right direction.
thank you very much.
VBA Code:
Dim fileName As String
Dim WS_name As Worksheet
Dim scrSht As Worksheet
Dim desSht As Worksheet
Dim wrkbook As Workbook
Dim wb As Workbook
Dim StrRow As Long
On Error GoTo ErrorHandler
' fileName = wrkbook.Sheets("REcords").Range("Filename").Value
Set wb = Workbooks.Open(fileName)
Set scrSht = ActiveSheet
Set wrkbook = Workbooks("Application.xlsm")
Set desSht = wrkbook.Sheets("sht_form")
StrRow = 2
' lastRow = desSht.Cells(Rows.Count, 1).End(xlUp).row
' lastcol = desSht.Cells(2, Columns.Count).End(xlToLeft).Column
For Each WS_name In Worksheets
Debug.Print WS_name.Name
If WS_name.Tab.ColorIndex = 16 Then
End If
If WS_name.Range("A1").Value = "CONFIRMATION" And WS_name.Tab.ColorIndex = xlColorIndexNone Then
desSht.Range("A2") = ThisWorkbook.Path
desSht.Range("B2") = ThisWorkbook.Name
desSht.Range("C2") = WS_name.Name
desSht.Range("D2") = WS_name.Range("B2:P2").Value
desSht.Range("E2") = WS_name.Range("B3").Value
' desSht.Range("F2") = WS_name.Range("").Value
' desSht.Range("G2") = WS_name.Range("").Value
Dim rng As Range, cell As Range
Dim R_Count As Long
R_Count = 1
Set rng = Range("Q1:AD33")
For Each cell In rng
If cell.Value <> "" Then
desSht.Cells(StrRow, templets.other1 + R_Count) = cell.Value
R_Count = R_Count + 1
End If
Next cell
Else
MsgBox "no"
End If
Next
StrRow = StrRow + 1
ErrorHandler:
MsgBox Err.Description, Err.Number
Last edited by a moderator: