对于Excel来说,我有点像VB的菜鸟,但我希望在接下来的几个月里能够做得更好。它可以让我的团队工作变得更轻松。有人可以帮我弄清楚如何让这个宏运行?我已经解决了一些问题,但欢迎任何专业知识。
我试图创建一个人们可以用人口普查数据填写的表单,然后我会在另一张表中运行这些数据的公式。
我目前在部件上收到突出显示的错误"表格(strName)。选择"
Sub InputSheet()
Dim sName As String
Dim sStatus As String
Dim sSalary As String
Dim sBonus As String
Dim sPartner As String
Dim sWorkState As String
Dim sBenefitsLevel As String
sName = InputBox("Input Employee Name:", "PROJECT INFORMATION")
sStatus = InputBox("Input FT or PT:", "PROJECT INFORMATION")
sSalary = InputBox("Input Salary:", "PROJECT INFORMATION")
sBonus = InputBox("Input Bonus:", "PROJECT INFORMATION")
sPartner = InputBox("Input Partner Status (Y/N):", "PROJECT INFORMATION")
sWorkState = InputBox("Input Work State:", "PROJECT INFORMATION")
sBenefitsLevel = InputBox("Input Benefits Level:", "PROJECT INFORMATION")
Dim MyNewSheet As Worksheet
Set MyNewSheet = Worksheets.Add(, Sheets(Sheets.Count))
Dim strName As String
strName = "Project Data "
Sheets(strName).Select
Cells(1, 1).Value = "Employee Name or Title"
Cells(1, 2).Value = "Employment Status"
Cells(1, 3).Value = "Salary"
Cells(1, 4).Value = "Bonus"
Cells(1, 5).Value = "Partner Status"
Cells(1, 6).Value = "Work State"
Cells(1, 7).Value = "Benefits Level"
Cells(2, 1).Value = sName
Cells(2, 2).Value = sStatus
Cells(2, 3).Value = sSalary
Cells(2, 4).Value = sBonus
Cells(2, 5).Value = sPartner
Cells(2, 6).Value = sWorkState
Cells(2, 7).Value = sBenefitsLevel
ThisWorkbook.Save
MsgBox "Process is Complete!"
End Sub
答案 0 :(得分:1)
strName末尾有空格 - 是名为“Project Data”或“Project Data”的标签吗?