Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disable a macrobutton for a particular cell change?


I am working on an excel database type file in which the master sheet is
used as data entry form and the values are stored in other sheets
designated for the particular month in the respective columns(one
column for one day)
Master sheet date is changed by calendar control and the calendar value
is used to get the name of the database sheet and the column.(December
2005, selected column etc)
After entering the values in the master sheet, the user either presses
a macro button named store or a toolbar button also named store.
User can also retrieve data by changing the date to required and
pressing a button named retrieve.
This is where the trouble starts! *If the user changes the date and
presses store instead of pressing retrieve, then the old data which is
already there in the database is lost!*
Is there anyway to disable the store button using the worksheet change
event, i.e., if the cell containing date is changed, the store button
should be disabled temporarily so that user can not by mistake click
it?
Hope I have explained my case clearly


--
lotus
------------------------------------------------------------------------
lotus's Profile: http://www.excelforum.com/member.php...o&userid=23759
View this thread: http://www.excelforum.com/showthread...hreadid=493216

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Disable a macrobutton for a particular cell change?

Anything is possible and what you are asking is not too bad to do at all. A
couple of question though... The button on the worksheet you want to disable;
Is it from the forms toolbar or from the control toolbox. The code is
different for the two buttons. If the button is from the control toolbox then
it should be as simple as addin this to the Sheet Change event:

Sheet1.CommandButton1.Enabled = False

If it is from the Forms toolbar then I might be more inclined to change the
button to check if the Date is not what was expected and warn the user and
abort the rest of the code.

Another question is what change to the date should re-enable the button.
--
HTH...

Jim Thomlinson


"lotus" wrote:


I am working on an excel database type file in which the master sheet is
used as data entry form and the values are stored in other sheets
designated for the particular month in the respective columns(one
column for one day)
Master sheet date is changed by calendar control and the calendar value
is used to get the name of the database sheet and the column.(December
2005, selected column etc)
After entering the values in the master sheet, the user either presses
a macro button named store or a toolbar button also named store.
User can also retrieve data by changing the date to required and
pressing a button named retrieve.
This is where the trouble starts! *If the user changes the date and
presses store instead of pressing retrieve, then the old data which is
already there in the database is lost!*
Is there anyway to disable the store button using the worksheet change
event, i.e., if the cell containing date is changed, the store button
should be disabled temporarily so that user can not by mistake click
it?
Hope I have explained my case clearly


--
lotus
------------------------------------------------------------------------
lotus's Profile: http://www.excelforum.com/member.php...o&userid=23759
View this thread: http://www.excelforum.com/showthread...hreadid=493216


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disable a macrobutton for a particular cell change?


Hi Jim,
Thanks for the quick response. The trouble is not actually enabling or
disabling the macro button.
I am only searching for a way to find if the user changes the date,
then that should trigger this event. May be something like storing the
old date in a variable and comparing it with the changed date.
The button can be re-enabled when the user pressed retrieve or when the
date is changed to the old date which is stored as a variable!

And yeah, it's a forms toolbar button!


--
lotus
------------------------------------------------------------------------
lotus's Profile: http://www.excelforum.com/member.php...o&userid=23759
View this thread: http://www.excelforum.com/showthread...hreadid=493216

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disable a macrobutton for a particular cell change?


Ok, I have solved it myself. *If there is a better method please tell me
guys*.

Also, I preferred to use a custom toolbar.

I added the following code to my *Retrieve *button:

'This stores the retrieved date in a distant cell(in my case it is
AF5:AH5)
'I have named the cells containing date as Date, Month & Year

With Sheets("Master")
..Range("AF5") = Range("Date")
..Range("AG5") = Range("Month")
..Range("AH5") = Range("Year")
End With

Then I added the following code to the *worksheet_calculate *event
procedu

If Range("Date") < Range("AF5") Or Range("Month") < Range("AG5") Or
Range("Year") < Range("AH5") Then
Application.CommandBars("My Tool Bar").Controls("Store").Enabled =
False
Else
Application.CommandBars("My Tool Bar").Controls("Store").Enabled =
True
End If

So, if the retrieved date does not match with the change in
calendar(which happens when the user changes the date) the *store
*button is disabled and the user will not click it accidentally and
spoil the database.
It is working fine for me.


--
lotus
------------------------------------------------------------------------
lotus's Profile: http://www.excelforum.com/member.php...o&userid=23759
View this thread: http://www.excelforum.com/showthread...hreadid=493216

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
disable brian baulsom's worksheet change based on cell value. jat Excel Worksheet Functions 2 April 22nd 09 07:16 AM
how to disable listbox change event Tom Ogilvy Excel Programming 0 July 27th 04 05:55 PM
Enable/Disable Worksheet Change Event code Stuart[_5_] Excel Programming 2 November 3rd 03 07:22 PM
Disable Change Event in Form No Name Excel Programming 5 October 31st 03 08:23 PM
Disable Worksheet change event Tim[_14_] Excel Programming 4 July 15th 03 01:27 AM


All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"