dimanche 24 février 2019

Add Text Value to a Userform TextBox if Checkbox value if statement is TRUE

I have a userform to update my currency analysis sheets. I have a checkbox on the top right that will dictate whether the date from date picker is holiday or not. If it is (meaning the checkbox is checked and therefore TRUE, then all of the textboxes will become a value of "HOL". If unchecked (or FALSE) the the textboxes will be a value of blank and I can enter the daily numbers before clicking the Submit command button to send to the sheets. Of course I would like the HOL to be the value sent to the sheets if the Checkbox value is TRUE. Please help...thanks in advance. The Check box name is HOLIDAY.

Here is the userform

Daily entry userform

and Here is the code

Private Sub HOLIDAY_Click()
    If Me.HOLIDAY.Value = True Then
    Me.DTPicker1.Value = "HOL"
    Me.JP_Open.Value = "HOL"
    Me.JP_Hi.Value = "HOL"
    Me.JP_Lo.Value = "HOL"
    Me.JP_Close.Value = "HOL"
    Me.CAD_Open.Value = "HOL"
    Me.CAD_Hi.Value = "HOL"
    Me.CAD_Lo.Value = "HOL"
    Me.CAD_Close.Value = "HOL"
    Me.GBP_Open.Value = "HOL"
    Me.GBP_Hi.Value = "HOL"
    Me.GBP_Lo.Value = "HOL"
    Me.GBP_Close.Value = "HOL"
    Me.Swiss_Open.Value = "HOL"
    Me.Swiss_Hi.Value = "HOL"
    Me.Swiss_Lo.Value = "HOL"
    Me.Swiss_Close.Value = "HOL"
    Me.AUD_Open.Value = "HOL"
    Me.AUD_Hi.Value = "HOL"
    Me.AUD_Lo.Value = "HOL"
    Me.AUD_Close.Value = "HOL"
    Me.Euro_Open.Value = "HOL"
    Me.Euro_Hi.Value = "HOL"
    Me.Euro_Lo.Value = "HOL"
    Me.Euro_Close.Value = "HOL"
    Me.EURJPY_Open.Value = "HOL"
    Me.EURJPY_Hi.Value = "HOL"
    Me.EURJPY_Lo.Value = "HOL"
    Me.EURJPY_Close.Value = "HOL"
    Me.AUDNZD_Open.Value = "HOL"
    Me.AUDNZD_Hi.Value = "HOL"
    Me.AUDNZD_Lo.Value = "HOL"
    Me.AUDNZD_Close.Value = "HOL"
    Me.EURNZD_Open.Value = "HOL"
    Me.EURNZD_Hi.Value = "HOL"
    Me.EURNZD_Lo.Value = "HOL"
    Me.EURNZD_Close.Value = "HOL"
    Me.NZDCAD_Open.Value = "HOL"
    Me.NZDCAD_Hi.Value = "HOL"
    Me.NZDCAD_Lo.Value = "HOL"
    Me.NZDCAD_Close.Value = "HOL"
    Me.NZDUSD_Open.Value = "HOL"
    Me.NZDUSD_Hi.Value = "HOL"
    Me.NZDUSD_Lo.Value = "HOL"
    Me.NZDUSD_Close.Value = "HOL"
    Me.NZDJPY_Open.Value = "HOL"
    Me.NZDJPY_Hi.Value = "HOL"
    Me.NZDJPY_Lo.Value = "HOL"
    Me.NZDJPY_Close.Value = "HOL"
    Me.GBPJPY_Open.Value = "HOL"
    Me.GBPJPY_Hi.Value = "HOL"
    Me.GBPJPY_Lo.Value = "HOL"
    Me.GBPJPY_Close.Value = "HOL"
Else
    Me.DTPicker1.Value = ""
    Me.JP_Open.Value = ""
    Me.JP_Hi.Value = ""
    Me.JP_Lo.Value = ""
    Me.JP_Close.Value = ""
    Me.CAD_Open.Value = ""
    Me.CAD_Hi.Value = ""
    Me.CAD_Lo.Value = ""
    Me.CAD_Close.Value = ""
    Me.GBP_Open.Value = ""
    Me.GBP_Hi.Value = ""
    Me.GBP_Lo.Value = ""
    Me.GBP_Close.Value = ""
    Me.Swiss_Open.Value = ""
    Me.Swiss_Hi.Value = ""
    Me.Swiss_Lo.Value = ""
    Me.Swiss_Close.Value = ""
    Me.AUD_Open.Value = ""
    Me.AUD_Hi.Value = ""
    Me.AUD_Lo.Value = ""
    Me.AUD_Close.Value = ""
    Me.Euro_Open.Value = ""
    Me.Euro_Hi.Value = ""
    Me.Euro_Lo.Value = ""
    Me.Euro_Close.Value = ""
    Me.EURJPY_Open.Value = ""
    Me.EURJPY_Hi.Value = ""
    Me.EURJPY_Lo.Value = ""
    Me.EURJPY_Close.Value = ""
    Me.AUDNZD_Open.Value = ""
    Me.AUDNZD_Hi.Value = ""
    Me.AUDNZD_Lo.Value = ""
    Me.AUDNZD_Close.Value = ""
    Me.EURNZD_Open.Value = ""
    Me.EURNZD_Hi.Value = ""
    Me.EURNZD_Lo.Value = ""
    Me.EURNZD_Close.Value = ""
    Me.NZDCAD_Open.Value = ""
    Me.NZDCAD_Hi.Value = ""
    Me.NZDCAD_Lo.Value = ""
    Me.NZDCAD_Close.Value = ""
    Me.NZDUSD_Open.Value = ""
    Me.NZDUSD_Hi.Value = ""
    Me.NZDUSD_Lo.Value = ""
    Me.NZDUSD_Close.Value = ""
    Me.NZDJPY_Open.Value = ""
    Me.NZDJPY_Hi.Value = ""
    Me.NZDJPY_Lo.Value = ""
    Me.NZDJPY_Close.Value = ""
    Me.GBPJPY_Open.Value = ""
    Me.GBPJPY_Hi.Value = ""
    Me.GBPJPY_Lo.Value = ""
    Me.GBPJPY_Close.Value = ""

End If
End Sub

If you need more information or more of my code. Thanks in advance once again.




Aucun commentaire:

Enregistrer un commentaire