How to stop merging specific sheet

srija

New Member
Joined
Jan 29, 2020
Messages
22
Office Version
  1. 2010
Platform
  1. Windows
  2. 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!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,217
Members
448,554
Latest member
Gleisner2

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