user3722021
user3722021

Reputation: 1

Ado multiple range select

I need get data from excel sheet from multiple range

RnG1 = "[" & SheetName & "$F1:G1000],"
RnG2 = "[" & SheetName & "$AI1:AI1000]"
RnG = RnG1 & RnG2
szSQL = "SELECT * FROM " & RnG$ & ";"

But somthing is wrong, how to select multiple range to copy data?

Upvotes: 0

Views: 477

Answers (1)

Rory
Rory

Reputation: 34045

Something like this, if you don't have column headers:

szSQL = "SELECT [F1], [F2], [F30] FROM [" SheetName & "$F1:AI1000];"

where F1, F2 etc indicates Field1, Field2 and so on. If you do have column headers use those in place of the F1 and F2.

Upvotes: 1

Related Questions