How to stop merging specific sheet

srija

New Member
Joined
Jan 29, 2020
Messages
19
Office Version
2010
Platform
Windows, Mobile
my macro is for merging multiple sheets in the file but it is merging menu sheet as well which should not merge.

Note: [sheet name is "menu" which should not merge]

How to stop merging specific sheet

Here is my coding:

VBA Code:
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Pending"
Sheets(2).Activate

Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For J = 2 To Sheets.Count
Sheets(J).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)

ThisWorkbook.Sheets("Pending").Range("A1").Value = "Vam"


ThisWorkbook.Sheets("Pending").Select

For Each sheet In ThisWorkbook.Worksheets
    If sheet.Name <> ThisWorkbook.ActiveSheet.Name Then
    sheet.Visible = xlSheetHidden
   
    
    End If
    Next sheet
Appreciate your help!
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
7,452
Office Version
2019
Platform
Windows
Assuming that the loop, For J = 2 to Sheets.Count is doing the merging, try inserting If Sheets(J).Name <> "Menu" Then after it.
Remember to insert an End If before the line Next J as well.
 

srija

New Member
Joined
Jan 29, 2020
Messages
19
Office Version
2010
Platform
Windows, Mobile
Assuming that the loop, For J = 2 to Sheets.Count is doing the merging, try inserting If Sheets(J).Name <> "Menu" Then after it.
Remember to insert an End If before the line Next J as well.

Thank you very much dude
 

Forum statistics

Threads
1,085,746
Messages
5,385,637
Members
401,963
Latest member
Broccolikid

Some videos you may like

This Week's Hot Topics

Top