Hi @Abdullah S. Alshehri,
The error code 400 in VBA typically means that there is an issue with the syntax of the code. It is difficult to provide a specific solution without seeing the code that is causing the error. However, based on the information provided, it sounds like you may need to consolidate data from multiple sheets into one sheet before running the report. You can do this using VBA code by copying the data from each sheet and pasting it into the consolidated sheet. Here is some sample code that you can modify to fit your specific needs:
Sub ConsolidateData()
Dim ws As Worksheet
Dim lastRow As Long
Dim destRow As Long
'Set the destination sheet
Set destSheet = ThisWorkbook.Sheets("ConsolidatedData")
'Loop through each sheet in the workbook
For Each ws In ThisWorkbook.Worksheets
'Skip the destination sheet
If ws.Name <> destSheet.Name Then
'Find the last row in the source sheet
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
'Copy the data to the destination sheet
ws.Range("A1:Z" & lastRow).Copy destSheet.Range("A" & destRow)
'Update the destination row counter
destRow = destSheet.Cells(destSheet.Rows.Count, "A").End(xlUp).Row + 1
End If
Next ws
End Sub
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.