Hidden sheet

topi1

Board Regular
Joined
Aug 6, 2014
Messages
162
Office Version
  1. 2010
Hi,
First of all, thanks to all who offer their valuable time and help. Much appreciated. I use the following code in my workbook from the "Home" sheet. I keep the sheets "123" and "Report-start" unhidden in order for macro to work. Is there a way to modify the following macro such that I can keep "123" and "Report-start" hidden? Please note that I password protect the entire workbook.
Many thanks.

Sub Finishall()
'
' Finishall Macro
'


'
Sheets("Report-start").Select


Columns("X:Z").Select
Selection.Copy


Sheets("123").Select
Columns("X:Z").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("123").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("123").Sort.SortFields.Add Key:=Range("Y1:Y82"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("123").Sort.SortFields.Add Key:=Range("Z1:Z82"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("123").Sort
.SetRange Range("X1:Z100")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("X:X").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With ActiveSheet.Cells
.ClearFormats
.Font.Name = Application.StandardFont
.Font.Size = Application.StandardFontSize




End With
Columns("Y").Replace 2, "#N/A", xlWhole
Intersect(Columns("X"), Columns("Y").SpecialCells(xlConstants, xlErrors).EntireRow).ClearContents
Columns("Y").Replace "#N/A", 2, xlWhole


LastRow = Cells(Rows.Count, "x").End(xlUp).Row
Range("x1:x" & LastRow).Copy


Sheets("Report-start").Select
Range("A1").Select
Sheets("123").Select
Range("A1").Select
Sheets("Home").Select
Range("O4").Select
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Instead of working toward hiding unhiding etc, is there a way to Keep "report-start" and "123" unhiden but password protected, and then to use some form of user interface protection?
Thanks.

not that I know of, BUT..

if you look at my code in Post #5, you can see I have screenupdating = False, this means the user will never actually see anything... and then you make the sheets go hidden again.
 
Last edited:
Upvote 0
Your code looks very recorded =P

But, the report-start sheet contains a template or just simple information?
 
Upvote 0
You did this to copy.


Code:
[COLOR=#333333]Sheets([/COLOR][COLOR=#ff0000]"Report-start"[/COLOR][COLOR=#333333]).Select[/COLOR]


[COLOR=#333333]Columns("X:Z").Select[/COLOR]
[COLOR=#333333]Selection.Copy[/COLOR]


[COLOR=#333333]Sheets([/COLOR][COLOR=#0000ff]"123"[/COLOR][COLOR=#333333]).Select[/COLOR]
[COLOR=#333333]Columns("X:Z").Select[/COLOR]
[COLOR=#333333]Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _[/COLOR]
[COLOR=#333333]xlNone, SkipBlanks:=False, Transpose:=False[/COLOR]
[COLOR=#333333]Application.CutCopyMode = False[/COLOR]


You could do this instead


Code:
[COLOR=#333333]Sheets([/COLOR][COLOR=#0000ff]"123"[/COLOR][COLOR=#333333]).[/COLOR][COLOR=#333333]Columns("X:Z").value = [/COLOR][COLOR=#333333]Sheets([/COLOR][COLOR=#ff0000]"Report-start"[/COLOR][COLOR=#333333]).Columns("X:Z").value[/COLOR]

Code looks so much cooler, and its faster..
 
Upvote 0
Keep the sheets hidden, do NOT Select or Activate and protect the sheets with argument UserInterfaceOnly set to True. Then you're good.
 
Upvote 0
Keep the sheets hidden, do NOT Select or Activate and protect the sheets with argument UserInterfaceOnly set to True. Then you're good.


Interresting, so you would do

Code:
userinterfaceonly = true

in the start of your code? and set it to False in the end?

or is it

Code:
Application.UserControl = True
 
Upvote 0
Interresting, so you would do

Code:
userinterfaceonly = true

in the start of your code? and set it to False in the end?

or is it

Code:
Application.UserControl = True

Protect sheets with Userinterfaceonly when opening the file (ThisWorkbook_Open event). That's all.
Unless you would Unprotect for some reason, in that case Protect again with the property set to True.
 
Upvote 0
Protect sheets with Userinterfaceonly when opening the file (ThisWorkbook_Open event). That's all.
Unless you would Unprotect for some reason, in that case Protect again with the property set to True.

Thx, useful to know :)
 
Upvote 0

Forum statistics

Threads
1,215,829
Messages
6,127,130
Members
449,361
Latest member
VBquery757

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