[英]VBA Excel ComboBox value to Range ("specific cell" to last column with data)
I am trying to fill a range of cells from a single ComboBox and I am not sure why my modified code of declaring range from cell down to last used row doesn't work when I flip it horizontally and declare range from cell to last used column on the right of the specified cell which is "C1"我正在尝试从单个 ComboBox 填充一系列单元格,我不确定为什么当我水平翻转它并声明从单元格到最后使用的列的范围时,我的修改代码从单元格到最后使用的行声明范围不起作用在指定单元格的右侧,即“C1”
Dim LastColumn As Long
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
Worksheets("Machine Format").Range("C2" & LastColumn).Value = UserForm_Home.Language_ComboBox.Text
I am judging if it's the last used column by it's header row which won't be blank.我正在判断它是否是最后使用的列,它是 header 行,它不会是空白的。
Could someone, please, help me with this code?有人可以帮我处理这段代码吗?
Since you're working with the column index, use Cells
instead of Range
.由于您正在使用列索引,因此请使用
Cells
而不是Range
。
With Worksheets("Machine Format")
.Range("C2", .Cells(2, LastColumn)).Value = UserForm_Home.Language_ComboBox.Text
End WIth
Use With Worksheets("Machine Format")
and a period .
With Worksheets("Machine Format")
和句点一起使用.
before Cells
to properly qualify the worksheet for the Cells
call.在
Cells
之前正确限定工作表以进行Cells
调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.