简体   繁体   中英

Define a range in excel vba

So I have the variable tstrng in a For loop and I want to set it equal to Columns C to Z at row "i", i being defined by the for loop iteration. I wrote the definition like this but the range keeps coming up as being empty and throwing a Runtime error. Any help on this issue would be greatly appreciated.

tstrng = wb1.Sheets("SourceData").Range("C" & i, "Z")

Try: tstrng = wb1.Sheets("SourceData").Range("C" & i, "Z" & i)

If i is 1 that will set tstrng to Range C1:Z1 in your SourceData worksheet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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