Unhide a very hidden sheet and hide the previous sheet

JiggersBass

New Member
Joined
May 20, 2022
Messages
13
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
The below macro doesn't work if I'm using xlSheetVeryHidden. Is there a way to make this work?

VBA Code:
Sub Test2()
'
' Test2 Macro
'
'
    Sheets("Sheet2").Select
    Sheets("Sheet1").Visible = xlSheetVisible
    Sheets("Sheet2").Select
    ActiveWindow.SelectedSheets.Visible = xlSheetVeryHidden
End Sub
 
Last edited by a moderator:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug. My signature block below has more details. I have added the tags for you this time. 😊

What about?

VBA Code:
Sub Test3()
  Sheets("Sheet1").Visible = xlSheetVisible
  Sheets("Sheet2").Visible = xlSheetVeryHidden
End Sub
 
Upvote 0
Solution
What happens is I get debug error and shows the line where the error is, but if I'm using below syntax, it works

Sub Summary_Report()
'
' Test2 Macro
'

'
Sheets("Report").Select
Sheets("Summary").Visible = True
Sheets("Report").Select
ActiveWindow.SelectedSheets.Visible = False
End Sub
Sub Summary_Return()
'
' Test2 Macro
'

'
Sheets("Summary").Select
Sheets("Report").Visible = True
Sheets("Summary").Select
ActiveWindow.SelectedSheets.Visible = False
End Sub
Sub Send_Report()
Dim r As Range
Set r = Range("b2:t27")
r.Copy
Dim outlookApp As Object
Set outlookApp = CreateObject("Outlook.Application")
Dim outMail As Object
Set outMail = outlookApp.CreateItem(0)
Dim strBody As String
strBody = "Hi Team," & vbNewLine & vbNewLine & _
"Kindly see attached and below report:"

With outMail
.display
.To = Range("b29").Value
.cc = Range("b30").Value
.Subject = Range("b31").Value
.body = strBody
Dim wordDoc As Object
Set wordDoc = .GetInspector.WordEditor
End With

With wordDoc
.Application.Selection.EndKey Unit:=6 'wdStory
.Application.Selection.TypeParagraph
.Application.Selection.PasteAndFormat 13 'wdChartPicture
End With

With Attached_File
Attached_File = "sample.xlsm"
outMail.Attachments.Add Attached_File
End With

'To paste as a table
'wordDoc.Range.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=False
End Sub

What I need to do is unhide the veryhidden sheet and hide the visible sheet using veryhidden attribute then send the file itself as an attachment.
 
Upvote 0
Please take note of my previous request!!
When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug. My signature block below has more details.


What happens is I get debug error and shows the line where the error is,
What is the full error message and what line does it show as the problem?
 
Upvote 0
Please take note of my previous request!!




What is the full error message and what line does it show as the problem?
I didn't use the very hidden anymore and was able to resolve the error. Thank you for the assistance.
 
Upvote 0

Forum statistics

Threads
1,213,565
Messages
6,114,338
Members
448,569
Latest member
Honeymonster123

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