我有一个用户表单来更新我的货币分析表。我在右上角有一个复选框,它将指示日期选择器中的日期是否为假日。如果是(意味着复选框已选中,因此为TRUE,则所有文本框将变为“ HOL”值。如果未选中(或FALSE),则文本框将为空白值,我可以在输入之前输入每日数字单击“提交”命令按钮发送到工作表。如果Checkbox值为TRUE,我当然希望将HOL作为发送到工作表的值。请提前帮助...谢谢。Checkbox名称为HOLIDAY。< / p>
这是用户表单
这是代码
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
如果您需要更多信息或更多我的代码。再次预先感谢。
我现在已经使用了这段代码,它确实允许我单击复选框并将HOL添加到所有字段...但是尝试清除文本框或关闭用户窗体时收到错误消息。
Private Sub Holiday_Click()
Dim ctrl As Control
With Me
For Each ctrl In .Controls
If TypeName(ctrl) = "TextBox" And .HOLIDAY = True Then
ctrl.Value = "HOL"
End If
Next ctrl
End With
End Sub
我不得不修改原始代码以排除上述ELSE语句
Else
ctrl.Value = ""
因为它会出错。