[英]Find data cell value, move up one cell in column, find next data cell within a column and get next value
使用下面的代码,我尝试执行以下操作:
建议,我无法使循环正常工作吗? 谢谢!
编辑:我可以获取前2个值,然后循环无限期运行,没有找到其他任何东西。
Dim strOutputFile As Variant
Dim wbkOut As Workbook
Dim tenln As Range
Dim tenlnPaste As Range
Dim hasRun As Boolean
Dim wbkVer As Workbook
If strOutputFile(u) Like "*Lines.csv" Then
With wbkOut.Worksheets(1)
Set tenln = wbkOut.Worksheets(1).Cells(Rows.Count, 2).End(xlUp)
Set tenlnPaste = wbkVer.Worksheets("TLines").Range("A" & .Rows.Count).End(xlUp).Offset(1).Resize(tenln.Rows.Count, 1)
tenlnPaste.Value = tenln.Value
hasRun = True
Do
If hasRun = True Then
With wbkOut.Worksheets(1)
tenlnPaste.Offset(1, 0).Value = tenln.Offset(-1, 0).End(xlUp).Value
End With
End If
Loop Until tenln.value = ""
End With
End If
do循环的问题在于您没有修改tenln
因此您在开始时设置的任何值都将保持不变,并且tenln = ""
始终为false
如果我正确阅读了tenln
sa范围对象,那么可以改用for循环。
For each c in tenln.cells
'your code here
If c.value = "" then exit for
Next
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.