我是宏的新手,但是对宏的工作原理有一定的了解,或者喜欢能够编写小的VBA代码。
是否可以在VBA代码内添加一些预定义的值,该值可以用作下拉值,以后可以使用,根据Google,有两种类型的响应,例如“是的,我们可以使用它”,还有一些响应说“不可能'。
我正在尝试创建报告。我必须用一些值保存它
1.预定义的值,例如(“ Analysis_Report”将是常数值)
2.下拉值(“ Cluster1”,“ Cluster2”,“其他”)-无法获取它
3.日期和时间戳
4. InputBox(“ UserName” )
但是我无法将下拉菜单(尝试使用ComboBox)设置为我的宏。如果有人可以帮助我更正我的代码,那将非常感激。:)
下面提供了我使用的一部分宏供您参考
Sub ImporttoNew_WorkBook_and_Close ()
Dim DT As String
Dim wbNam As String
Dim Path
Dim Cluster
Dim UserName
Workbooks.Add
wbName = "Analysis_Report"
DT = Format(CStr(Now), "yyyy_mm_dd_hh_mm_ss")
Path = InputBox("Enter Path ", "Enter value") & "\"
UserName = "_" & InputBox("Type your Name", "Enter value")
Cluster = ComboBox1.List = Array("Cluster1", "Cluster2", "Other") **'Not Working**
ActiveWorkbook.SaveAs Filename:=Path & Cluster & wbName & DT & UserName
ActiveWorkbook.close
MsgBox "Document saved"
End Sub
提前致谢。:)
组合框的问题在以下行中:
Cluster = ComboBox1.List = Array("Cluster1", "Cluster2", "Other") **'Not Working**
您必须先将cluster设置为组合框,然后分配值:
Set Cluster = Tabelle1.ComboBox1 'change Tabelle1 to the Codename of the worksheet with your combobox1 in it
Cluster.List = Array("Cluster1", "Cluster2", "Other")
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句