![](/img/trans.png)
[英]Excel VBA Copy/Paste Range to the next available cell in another worksheet
[英]how to select the row of combobox value then copy and paste to another worksheet range using command button with VBA Excel
我的用户表单包含一个组合框和一个命令按钮。
通过在我的组合框的属性中的行源字段中标识我的范围clmA,可以用range(“ clmA”)填充组合框列表。 (未使用VBA填充列表)
我想要一个子button_click()选择组合框中的值所标识的数据行,并将该行粘贴到另一个工作表中。
我希望复制和粘贴代码应该不是问题,但是我似乎无法引用或选择组合框中的值。
我只是在学习VBA,而是通过阅读此网站并使用宏记录器来学习。
将列更改为所需的任何内容,
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim Drng As Range, c As Range
Set ws = Sheets("Data")
Set Drng = ws.Columns("A:A").SpecialCells(xlCellTypeConstants, 23)
For Each c In Drng.Cells
If c = ListBox1 Then
Range(Cells(c.Row, "A"), Cells(c.Row, "D")).Copy Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End If
Next c
Unload Me
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.