View Full Version : Make other cells invisible or locked programmatically
gopi09_m
10-27-2009, 02:16 AM
Hi
I only want the cells E4:M22 visible in excel sheet.I want all other cells to be not visible or locked.Preferably not visible.
I want to the view the excel only with the cells from E4:M22 .I dont want to see anyother options visible in Excel.No Menu options should be visible.
so it looks like a rectangle.something like in snakes game..like below.
http://github.com/qrush/snake/tree/master%2Fscreenshot.png?raw=true
Regards,
Krrishna
mdmackillop
10-27-2009, 06:54 AM
Sub E4M22()
Rows("1:3").Hidden = True
Rows("23:65536").Hidden = True
Columns("A:C").Hidden = True
Columns("N:IV").Hidden = True
End Sub
JP2112
10-27-2009, 07:02 AM
This will get you most of the way there:
Sub tst()
Dim wksht As Excel.Worksheet
Dim rowsCount As Long
Set wksht = ActiveSheet
rowsCount = wksht.Rows.Count
wksht.ScrollArea = "E4:M22"
Union(Range("A1:IV3"), Range("A23:IV" & rowsCount)).RowHeight = 0
Union(Range("A4:D" & rowsCount), Range("N4:IV" & rowsCount)).ColumnWidth = 0
ActiveWindow.DisplayHeadings = False
End Sub
gopi09_m
10-27-2009, 07:48 AM
Its great help to me.I am trying to resize the window to the cells E4:M22 so that it looks small.
Application.WindowState = xlNormal
Now i have to hide the Menu options like File,Edit and so on..
mdmackillop
10-27-2009, 08:02 AM
Make sure you have a way to get them back!
gopi09_m
10-27-2009, 08:05 AM
:-) Yes. Thats why i am trying it programmatically.I will post the full code once i am successfull.
gopi09_m
11-11-2009, 08:34 AM
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("Help").Visible = True
Application.CommandBars("Worksheet Menu Bar").Controls("File").Visible = True
Application.CommandBars("Worksheet Menu Bar").Controls("Edit").Visible = True
Application.CommandBars("Worksheet Menu Bar").Controls("View").Visible = True
Application.CommandBars("Worksheet Menu Bar").Controls("Insert").Visible = True
Application.CommandBars("Worksheet Menu Bar").Controls("Format").Visible = True
Application.CommandBars("Worksheet Menu Bar").Controls("Tools").Visible = True
Application.CommandBars("Worksheet Menu Bar").Controls("Data").Visible = True
Application.CommandBars("Worksheet Menu Bar").Controls("Window").Visible = True
Application.DisplayFormulaBar = True
Application.Caption = ""
Application.StatusBar = True
Application.DisplayScrollBars = True
Application.Width = 100
On Error GoTo 0
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.