我正在尝试填充大小未知的范围,因为用户可以在第一组中选择多达 15 个项目。这将被插入到某一行。
我有一个带有以下名称/值的复选框:
Name Value
========== =====
chk_week1 1
chk_week2 2
... ...
... ...
chk_week15 15
例如,如果用户选择chk_week1、chk_week2、chk_week4和chk_week5,则应将其作为 1、2、4、5 插入到单元格中。
我已经包含了一张图片,以更好地展示它:
每个复选框都有上表中列出的名称和值。这是我到目前为止使用的代码:
Private Sub btnSubmit_Click()
Dim ws As Worksheet
Dim rng1 As Range
Set ws = Worksheets("main")
' Copy the data to the database
' Get last empty cell in column A
Set rng1 = ws.Cells(Rows.Count, "a").End(xlUp)
deptCodeSplit = Split(cbo_deptCode.Value, " ")
' Having difficulty adding the code here
' rng1.Offset(1, 6) = weeks
End Sub