Loop through sheets until blank sheet.

Mayank1502

New Member
Joined
Jun 5, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,
I have 20 sheets in my workbook and I need to consolidate the first 13 sheets one below the other, However, those are monthly sheets and data in those sheets will be pasted every month.
for e.g-
I have 13 sheets named as January, February, March, April, May … and there is no data in sheet 'June'. Hence the loop should only compile sheets till may and then exit the loop.
Request if anybody can help me with the code for this.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
This code simply checks to see if cell A1 in each of the first 13 sheets contains data. Any sheet with a blank A1 is ignored.
VBA Code:
Sub test()
    Application.ScreenUpdating = False
    Dim x As Long
    For x = 1 To 13
        If Sheets(x).Range("A1") <> "" Then
            'your code here
        End If
    Next x
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,055
Messages
6,122,902
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top