commandbutton Enabled and Disabled

adeel1
2StarLounger
Posts: 186
Joined: 04 Oct 2017, 15:47

commandbutton Enabled and Disabled

Post by adeel1 »

Hi All, Refer to attachment
When WB will open double click in any cell commandbutton will get enable then click commandbutton it will deactivate then double click on any cell it will not enabled, all goods
But issue is this if you close WB and open again and Double click on any cell command button get enabled which I donot want till condition(here i am stuck to make condition)

Actually, I have generated Roster with some code, Roster is based on month I only want this commandbutton enabled once day in a month and if user hit it Roster will generated than this commandbutton disable till next month date

Below is generating dates where I need date which I set at that day this command button will enable and after hitting once it should disable till next date.
Note: if you are looking for dates condition may I can manage, issue is this when condition will met at that date only disabled button after one click (not leave enabled button for 24 Hours)

Code: Select all

vnn = Evaluate("INDEX(FILTER(SEQUENCE(DAY(EOMONTH(TODAY(),0)),1,TODAY()-DAY(TODAY())+1,1),TEXT(SEQUENCE(DAY(" & _
                "EOMONTH(TODAY(),0)),1,TODAY()-DAY(TODAY())+1,1),""ddd"")=""Mon""),1)<TODAY()")
For testing purpose it is like this <TODAY()") otherwise it will be >TODAY()") in above formula
Adeel
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 73825
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: commandbutton Enabled and Disabled

Post by HansV »

There is no Worksheet_BeforeDoubleclick event procedure... :scratch:
Regards,
Hans

adeel1
2StarLounger
Posts: 186
Joined: 04 Oct 2017, 15:47

Re: commandbutton Enabled and Disabled

Post by adeel1 »

Hi,
that code is under Worksheet_Change event
Adeel

Code: Select all

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo myerror
Application.EnableEvents = False
'Application.Wait (Now + TimeValue("0:00:5"))

vnn = Evaluate("INDEX(FILTER(SEQUENCE(DAY(EOMONTH(TODAY(),0)),1,TODAY()-DAY(TODAY())+1,1),TEXT(SEQUENCE(DAY(" & _
                "EOMONTH(TODAY(),0)),1,TODAY()-DAY(TODAY())+1,1),""ddd"")=""Mon""),1)<TODAY()")



If vnn(1) = True Then
With CommandButton1
.Caption = "Generate Roster"
.Enabled = True
.BackColor = vbGreen

End With
End If
ThisWorkbook.Save
myerror:
Application.EnableEvents = True
End Sub

User avatar
HansV
Administrator
Posts: 73825
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: commandbutton Enabled and Disabled

Post by HansV »

That code runs after the user has changed the value of a cell, not when the user double-clicks a cell.
Anyhow, I'm afraid I don't have the slightest idea what you want, sorry.
Regards,
Hans

adeel1
2StarLounger
Posts: 186
Joined: 04 Oct 2017, 15:47

Re: commandbutton Enabled and Disabled

Post by adeel1 »

can commandbutton restrict like open WB click on commandbutton , its disabled but it should not enabled till for sameday even WB close then open again

Adeel

User avatar
HansV
Administrator
Posts: 73825
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: commandbutton Enabled and Disabled

Post by HansV »

No idea.
Regards,
Hans

adeel1
2StarLounger
Posts: 186
Joined: 04 Oct 2017, 15:47

Re: commandbutton Enabled and Disabled

Post by adeel1 »

:thumbup:

Adeel