disable a comman button after one click then

mahhogany

New Member
Joined
Jul 28, 2008
Messages
20
enable it again 28 days later?

Is this possible?

I have a command button that copy and pastes data but this information only needs to be done every month. Any help with the VBA code?
 
Last edited:
The Macro which is allocated to this command button will run after a manual click but I don't want users to click on it multiple times as it will corrupt the data.

Idealy I want the user to click on the button once to run the macro which will copy and paste the data.
If they click on it a second time I want a message box to pop up instructing them that they have already done so this month etc.
 
Upvote 0
Isn't there some way of determining that it has already been run for the current month? You can exit the procedure if that condition is true?
 
Upvote 0
Isn't there some way of determining that it has already been run for the current month? You can exit the procedure if that condition is true?
There isn't anything particuarly in the sheet. I was thinking that there could be maybe some sort of VBA timestamp function which could determine this. i.e. the date the macro is run is recorded and then every 28 days after that.
 
Upvote 0
You could store the date it's run in a spare cell somewhere and deduct from today's date. If the difference is less than 28 days exit the sub, otherwise run the macro and update the date run.
 
Upvote 0
You could store the date it's run in a spare cell somewhere and deduct from today's date. If the difference is less than 28 days exit the sub, otherwise run the macro and update the date run.
Thanks

Any tips for the code?

Alternatively I have this code below in sheet 1

Private Sub Refresh_Graph_Data_Click()
CopyGraphValues 'name of macro
Refresh_Graph_Data.Enabled = False
'name of button
End Sub

Which disables the button after one click. However how do I get it enabled again on workbook open? I was thinking that I could try this option togther with a message box instructing them to press the button once.

I put this code in the workbook but it won't work.

Sub Workbook_Open()
Workbook ("sheet 1")
.Refresh_Graph_Data.Enabled = True
End Sub
 
Upvote 0
If the code is in the module for the worksheet that contains the CommandButton:

Code:
Me.Refresh_Graph_Data.Enabled = False

Otherwise:

Code:
Worksheets("Sheet 1").OLEObjects("Refresh_Graph_Data").Object.Enabled = True
 
Upvote 0

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