简体   繁体   English

Excel VBA使用偏移量移至下一行

[英]Excel VBA Use Offset to Move To Next Row

I want to place results in successive rows using the offset property if possible. 如果可能,我想使用offset属性将结果放置在连续的行中。

Line 9 is where I am having trouble getting the correct syntax. 第9行是我无法获取正确语法的地方。

Set startcell2 = Worksheets("Duplicates").Cells(1, 1)

rs.Open "Select dmdrawno From webprddt1.drawmstrp Where dmdrawno = '" & dwgno & "'", oConn, adOpenKeyset, adLockOptimistic

If Not rs.EOF Then
    'addnewrecord = False
Else
    startcell2.Value = dwgno
    startcell2.Offset(1, 0)
    addnewrecord = False

End If

rs.Close
Set rs = Nothing

Line 9 should read 第9行应显示为

Set startcell2 = startcell2.Offset(1, 0)

and then preferably be in a loop where you read the records 然后最好是在循环中读取记录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM