所以我要做的就是通过底部#是命令我的列表1。在这样做的过程中,我将把所有信息都移到右边。然后我将在我的选择的底部找到列B中列表的底部然后离开1,找到底部A列填充#系统一直到列表的底部
Private Sub CommandButton2_Click()
'My problem is i don't know what to set "Dim y As Range" I know Range is
'incorrect along with Long, and Integer.
Dim y As Range
Sheets("PalmFamily").Select
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "1"
Range("A2").Select
ActiveCell.FormulaR1C1 = "2"
Range("A3").Select
ActiveCell.FormulaR1C1 = "3"
Range("A1:A3").Select
'As you can notice I also have a weird code
'" y = Range("B1").End(xlDown).Offset(0, -1)" I'm trying to go to the bottom
'of my list then move left 1.
y = Range("B1").End(xlDown).Offset(0, -1)
'As well the I'm not sure if I set my range to be correct when I do
'"Range("A1,y")"
Selection.AutoFill Destination:=Range("A1,y"), Type:=xlFillDefault
Range("A1,y").Select
End Sub
答案 0 :(得分:2)
您发布的代码无法编译,我只能通过查看来判断它。
您已声明y As Range
这是一个对象,在分配时需要Set
关键字。
Set y = Range("B1").End(xlDown).Offset(0, -1)
此外,Range("A1,y")
是我在两个地方看到的语法错误。我认为,这两个都应改为:
Range("A1", y)
请注意,逗号和“y”未包含在引号中。