Combine WLD Worksheets Into an Excel Summary With VBA
Question details
Create a reusable VBA macro that combines filtered data from WLD worksheets into a Summary sheet as values.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A workbook contains multiple similarly structured worksheets whose names begin with WLD.
- Observed behavior
- The desired result is a Summary sheet containing the nonblank source rows from all matching worksheets, without formulas.
Create a sheet named Summary with headers in A1:E1, and confirm that each WLD sheet has headers in F2:J2 and data in F3:J147. Reserve columns A:E below the Summary headers for the macro; existing filters on matching sheets will be removed.
Run a VBA macro to consolidate WLD sheet values
Use this macro when all matching worksheets share the same source range and you want to refresh the Summary each time.
The macro matches sheet names beginning with WLD, filters column F for nonblank entries, and writes visible rows from columns F:J as values. Manually hidden rows are also excluded.
To match only names beginning with WLD followed by a space and hyphen, replace Like "WLD*" with Like "WLD -*".
Open the workbook in Excel, open the Visual Basic Editor from Developer > Visual Basic, and select Insert > Module.
Paste this code into the new module: Sub SummarizeWLD() Dim ws As Worksheet, target As Worksheet, filteredSheet As Worksheet Dim rowNum As Long, nextRow As Long Dim oldScreenUpdating As Boolean Dim errorText As String oldScreenUpdating = Application.ScreenUpdating On Error GoTo HandleError Application.ScreenUpdating = False Set target = ThisWorkbook.Worksheets("Summary") target.Range("A2:E" & target.Rows.Count).ClearContents nextRow = 2 For Each ws In ThisWorkbook.Worksheets If ws.Name Like "WLD*" Then Set filteredSheet = ws If ws.AutoFilterMode Then ws.AutoFilterMode = False ws.Range("F2:J147").AutoFilter Field:=1, Criteria1:="<>" For rowNum = 3 To 147 If Not ws.Rows(rowNum).Hidden Then target.Cells(nextRow, 1).Resize(1, 5).Value2 = _ ws.Cells(rowNum, 6).Resize(1, 5).Value2 nextRow = nextRow + 1 End If Next rowNum ws.AutoFilterMode = False Set filteredSheet = Nothing End If Next ws GoTo CleanUp HandleError: errorText = Err.Description CleanUp: On Error Resume Next If Not filteredSheet Is Nothing Then filteredSheet.AutoFilterMode = False Application.ScreenUpdating = oldScreenUpdating On Error GoTo 0 If Len(errorText) > 0 Then MsgBox "Summary stopped: " & errorText, vbExclamation End Sub
Save the workbook as an Excel Macro-Enabled Workbook (.xlsm). In Excel, choose Developer > Macros, select SummarizeWLD, and click Run. Check the results on the Summary sheet.

Work with summary spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open compatible Excel files and move your everyday spreadsheet work to WPS with minimal disruption; this Excel VBA macro is not a fix for WPS.

Frequently Asked Questions
Why does the macro skip a worksheet?
Check that the sheet name begins with WLD. If you changed the Like pattern to "WLD -*", the name must also include the space and hyphen.
Does the Summary retain formulas from the source sheets?
No. The macro assigns Value2 from F:J to Summary columns A:E, so it copies the displayed cell values rather than the formulas.
How do I include more than 145 data rows?
Change both F2:J147 in the AutoFilter line and the upper limit in For rowNum = 3 To 147 to cover the required rows.
What happens to existing filters on WLD sheets?
The macro removes existing AutoFilters before applying its own filter and turns its filter off afterward. It does not restore the previous filter settings.
Why can't I save the macro in an .xlsx file?
Excel's .xlsx format does not retain VBA code. Choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm).




