Excel VBA code o hide a worksheet once copied and saved

Tony_Y

New Member
Joined
May 29, 2020
Messages
35
Office Version
  1. 365
Platform
  1. Windows
Good evening,

Thanks to this forum and it's members I have a code which copies and saves a worksheet, naming it he value of a cell from another worksheet. I am now after taking this a little further and:

1. Hiding the newly saved sheet and
2. Unhiding and activating sheet 16.

Any help will be greatly appreciated

TIA

Tony

VBA Code

VBA Code:
Private Sub CommandButton2_Click()

   Dim shtName As String
  
   shtName = Sheet22.Range("D64").Value

   If Evaluate("isref('" & shtName & "'!A1)") Then

      MsgBox "Sheet Already Exists"

   Else
      Sheet14.Copy , Sheets(Sheets.Count)

      ActiveSheet.Name = shtName

      Sheet14.Activate

      Range("E9:E19,E38:E46,K9:K16,K38:K39").Value = 0

      MsgBox "Sheet Saved Success"

      Sheet16.Activate
     

   End If

End Sub
 
Last edited by a moderator:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
How about
VBA Code:
      Sheet14.Copy , Sheets(Sheets.Count)

      With ActiveSheet
         .Name = ShtName
         .Visible = xlSheetHidden
      End With
      Sheet14.Range("E9:E19,E38:E46,K9:K16,K38:K39").Value = 0

      MsgBox "Sheet Saved Success"

      Sheet16.Visible = xlSheetVisible
 
Upvote 0
Hi Fluff,

That works great very many thanks (sorry for late reply - working).

kind regards

Tony
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,414
Messages
6,119,375
Members
448,888
Latest member
Arle8907

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