循环给单元格赋值的问题!

brucelee717 2010-07-29 10:01:31
Dim rRow As Long, Tol As Long, cols As Long, TValue As String, CValue As String
TValue = Target.Value
Tol = 0
cols = 1
rRow = Sheet3.UsedRange.Find("接入间").Row + 1
If Target.Address = "$H$3" Then


Set c = Sheet1.UsedRange.Find(TValue)

If Not c Is Nothing Then
firstAddress = c.Address

Do
CValue = c.Offset(0, -2)
Sheet3.Cells(rRow, cols).Value = CValue

Set c = Sheet1.UsedRange.FindNext(c)
cols = cols + 1
Loop While Not c Is Nothing And c.Address <> firstAddress
End If




End If

为什么我这一句老是出错 Sheet3.Cells(rRow, cols).Value = CValue 我都快疯了
...全文
227 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
龙湖金风 2010-08-05
  • 打赏
  • 举报
回复
Excel最多256列,估计是列越限了
dsd999 2010-07-29
  • 打赏
  • 举报
回复
看看rRow和cols的值是不是合法
hahaxiaoa 2010-07-29
  • 打赏
  • 举报
回复
Sheet3.Cells(rRow, cols) = CValue
这样试下?
ACMAIN_CHM 2010-07-29
  • 打赏
  • 举报
回复
出错信息是什么? 调试中看一下此时的rRow, cols 的值是什么?

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧