How to find the range of a web query on a Excel worksheet

B

Belinda

I have a web query on one of the worksheet and I want VBA to obtain
the range in which the web query as populated the results from VBA.

Can you kindly advise how I can determine the range of cells populated
by the web query.

Also, in general when we have a range of values populated on a Excel
worksheet how can we progammatically determine the range of cells
populated in the worksheet.

Thanks
Belinda
 
G

Gjones

Hi Belinda;

After the recordset has returned use this code.

'Select a cell somewhere in the range probably

Range("A1").Select

'Then use the current region method

ActiveCell.CurrentRegion.Select

'Then get the address

MyRange = Selection.Address

'The values for Address are read only.

Thanks,

Greg
 
T

Tom Ogilvy

You don't have to select of course.

set rng = Range("A1").CurrentRegion
msgbox rng.Address(external:=True)
 
D

Dana DeLouis

Would this work for you?

Sub FindQueryAddress()
Dim QueryAddress As String
QueryAddress = ActiveSheet.QueryTables(1).ResultRange.Address(False,
False)
End Sub


HTH
Dana DeLouis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top