Restrict Sort on a Particular Sheet

  • Thread starter Thread starter Ritesh S
  • Start date Start date
R

Ritesh S

I have created a sheet with all the numbers at specific
location and i am working on writing a code in VB to find
the location of those numbers and Graph it.

What i am having trouble is to make is so that nobody can
sort that one particular sheet...b/c that could cause all
my graphs to mess up...

If anybody can help me I'd really appreciate it.

Thanks in advance...

Sincerely,
Ritesh
 
Hi

Try this two events in the sheet module Ritesh

Private Sub Worksheet_Activate()
With Application.CommandBars("Standard")
.FindControl(ID:=210).Enabled = False
.FindControl(ID:=211).Enabled = False
End With
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=928, Recursive:=True).Enabled = False
End Sub

Private Sub Worksheet_Deactivate()
With Application.CommandBars("Standard")
.FindControl(ID:=210).Enabled = True
.FindControl(ID:=211).Enabled = True
End With
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=928, Recursive:=True).Enabled = True
End Sub
 
Thank you so much...but I just wanted to clearify your
instructions...

Did you want me to put this Code in Sheet(Code) or in a
Module... and if you would please tell me what 1st part
and 2nd part does

Thanks again
Sincerely,
Ritesh
-----Original Message-----
Hi

Try this two events in the sheet module Ritesh

Private Sub Worksheet_Activate()
With Application.CommandBars("Standard")
.FindControl(ID:=210).Enabled = False
.FindControl(ID:=211).Enabled = False
End With
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=928, Recursive:=True).Enabled = False
End Sub

Private Sub Worksheet_Deactivate()
With Application.CommandBars("Standard")
.FindControl(ID:=210).Enabled = True
.FindControl(ID:=211).Enabled = True
End With
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=928, Recursive:=True).Enabled = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ritesh S" <[email protected]> wrote
in message news:[email protected]...
 
Hi Ritesh

This are sheet events
The code will disable the Sort controls when you activate the
worksheet and enabled them when you deacitvate the Sheet

Right click on a sheet tab and choose view code
Paste the code there
Alt-Q to go back to Excel

If you copy the events in Sheet2 for example then you can use this
events in the ThisWorkbook module to be sure that the controls are working
if you go to a other file or save the file
It will select a other sheet so the deactivate event will run


Right click on the Excel icon next to File in the menubar
And choose View code

You are now in the Thisworkbook module
Paste the Event in this place
Alt-Q to go back to Excel

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ThisWorkbook.Sheets("Sheet1").Activate
End Sub

Private Sub Workbook_Deactivate()
ThisWorkbook.Sheets("Sheet1").Activate
End Sub


Read Chip Pearson's site about Events
http://www.cpearson.com/excel/events.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top