JamesMcS
Keyboard-Chair Interface
- Local time
- Today, 14:46
- Joined
- Sep 7, 2009
- Messages
- 1,819
G'day all, long time... Hope everyone's well!
I've got this spreadsheet with four tabs on it. Three of them have querytables looking at an Access DB and all is well. But...
I want to change some of the criteria in a couple of the queries to reflect what's in a particular cell on the spreadsheet - this bit I can do I think, by changing the commandtext for each of them. However I can't reference the querytables themselves - it seems as though Excel thinks there are no querytables in any of the sheets! The following code returns 0 for each sheet:
Where am I going wrong guys??
Edit: (I should mention that the queries I want to change were created with Microsoft Query) (Oh, and I'm using Access and Excel 2007)
I've got this spreadsheet with four tabs on it. Three of them have querytables looking at an Access DB and all is well. But...
I want to change some of the criteria in a couple of the queries to reflect what's in a particular cell on the spreadsheet - this bit I can do I think, by changing the commandtext for each of them. However I can't reference the querytables themselves - it seems as though Excel thinks there are no querytables in any of the sheets! The following code returns 0 for each sheet:
Code:
Dim Wkbk As Workbook
Dim Wksht As Worksheet
Dim QTbl As QueryTable
Set Wkbk = ThisWorkbook
For Each Wksht In Wkbk.Worksheets
Debug.Print Wksht.Name
Debug.Print Wksht.QueryTables.Count
Next Wksht
End Sub
Edit: (I should mention that the queries I want to change were created with Microsoft Query) (Oh, and I'm using Access and Excel 2007)