gpt4 book ai didi

VBA 问题 - 从输入框将数据存储在数组中

转载 作者:行者123 更新时间:2023-12-01 23:20:36 25 4
gpt4 key购买 nike

我是 VBA 的新手,所以我很乐意将输入框的值存储到数组中,我写了下面的代码,然后我尝试定义一个数组来存储它们,我的 VBA 代码有问题,你能不能帮忙查一下?任何帮助将不胜感激

Sub inpubox()
Dim sn As String
Dim em_ID As String
Dim name As String
Dim dept As String
Dim hostname As String
Dim loc As String
sn = InputBox("Enter Laptop's Serial")
em_ID = InputBox("Enter Colleague ID")
name = InputBox("Enter Colleague Name")
dept = InputBox("Enter Colleague department")
loc = InputBox("Enter office location")
'Xu li hostname
hostname = "VN" & loc & sn
sodong = Sheet1.Range("A" & Rows.Count).End(xlUp).Offset(1).row
Dim arr6 As String
arr6 =(sn,em_id,name,dept,hostname,loc)

End Sub

错误也附上 array error

最佳答案

Sub ShortCode()
arr = Array(InputBox("Enter Laptop's Serial"), InputBox("Enter Colleague ID"), _
InputBox("Enter Colleague Name"), InputBox("Enter Colleague department"), _
InputBox("Enter office location"))
Sheet1.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, UBound(arr) + 1) = arr
End Sub

关于VBA 问题 - 从输入框将数据存储在数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68152421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com