VB,中如何选定单元格区域
答案:2 悬赏:80 手机版
解决时间 2021-02-24 05:06
- 提问者网友:骨子里的高雅
- 2021-02-23 06:09
VB,中如何选定单元格区域
最佳答案
- 五星知识达人网友:三千妖杀
- 2021-02-23 07:14
cells(x,y).追问应该是四个变量,该如何引用?谢谢!!追答cells(x,y)
这里,x表示行,y表示列,
A1=cells(1,1)
B7=cells(2,7)
for x=1 to 2
for y=1 to 7
cells(x,y)
next
next追问谢谢先,不过好象不是这样。
在VB中选择A1至B7单元格,然后复制。
range("A1:B7").select
selection.copy
当A1、B7都是变量时,代码该如何写?谢谢!
注:应该是四个变量。
我这样写,提示出错:
Range(CStr(Cells(56, 2 + iq * 2)) & ":" & CStr(Cells(56, 2 + iq * 2))).Select追答Private Sub CommandButton1_Click()
Dim x As Integer, y As Integer
For x = 1 To 7
For y = 1 To 2
With Sheet1
.Cells(x, y + 3) = .Cells(x, y)
End With
Next
Next
End Sub
Private Sub CommandButton2_Click()
Sheet1.Range("A1:B7").Select
Selection.Copy
End Sub
Private Sub CommandButton2_Click()
Dim s As String
Dim x As Integer, y As Integer
Dim a As Integer, b As Integer
x = 1
y = 1
a = 2
b = 7
s = Chr(64 + x) & y & ":" & Chr(64 + a) & b
Sheet1.Range(s).Select
Selection.Copy
End Sub
'上面两段代码的效果一样,已经调试成功!
这里,x表示行,y表示列,
A1=cells(1,1)
B7=cells(2,7)
for x=1 to 2
for y=1 to 7
cells(x,y)
next
next追问谢谢先,不过好象不是这样。
在VB中选择A1至B7单元格,然后复制。
range("A1:B7").select
selection.copy
当A1、B7都是变量时,代码该如何写?谢谢!
注:应该是四个变量。
我这样写,提示出错:
Range(CStr(Cells(56, 2 + iq * 2)) & ":" & CStr(Cells(56, 2 + iq * 2))).Select追答Private Sub CommandButton1_Click()
Dim x As Integer, y As Integer
For x = 1 To 7
For y = 1 To 2
With Sheet1
.Cells(x, y + 3) = .Cells(x, y)
End With
Next
Next
End Sub
Private Sub CommandButton2_Click()
Sheet1.Range("A1:B7").Select
Selection.Copy
End Sub
Private Sub CommandButton2_Click()
Dim s As String
Dim x As Integer, y As Integer
Dim a As Integer, b As Integer
x = 1
y = 1
a = 2
b = 7
s = Chr(64 + x) & y & ":" & Chr(64 + a) & b
Sheet1.Range(s).Select
Selection.Copy
End Sub
'上面两段代码的效果一样,已经调试成功!
全部回答
- 1楼网友:我住北渡口
- 2021-02-23 08:31
Range(CStr(Cells(56, 2 + iq * 2)) & ":" & CStr(Cells(56, 2 + iq * 2))).Select
如果这行出错,设置个断点看看 CStr(Cells(56, 2 + iq * 2)) & ":" & CStr(Cells(56, 2 + iq * 2)) 这个东西组合出来是什么样的。因为参数就是一个字符串,可以自己组合的,但是必须符合格式而已
如果这行出错,设置个断点看看 CStr(Cells(56, 2 + iq * 2)) & ":" & CStr(Cells(56, 2 + iq * 2)) 这个东西组合出来是什么样的。因为参数就是一个字符串,可以自己组合的,但是必须符合格式而已
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯