Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's the problem I'm having with the code below.
If the worksheet contains no query-table the codes exits the inner loop (For Each qt) and moves to the next worksheet with no error. However, when the worksheet does contains a query-table the code exits the inner loop but fails when it hits the 'Next ws'. At that point it returns a "'Run-time error '13': type mismatch". If I choose debug and then resume the codes continues until it encounters the next sheet with a query-table. Any advice will be appreciated Buck ================================================== === Dim ws As Worksheet Dim wsName As String Dim pt As PivotTable Dim ptname As String Dim qt As QueryTable Dim qtname As String 'Loop through all sheets and updates all QueryTables Set wb = ActiveWorkbook For Each ws In wb.Sheets wsName = ws.Name For Each qt In ws.QueryTables qtname = qt.Name Worksheets(wsName).Activate Range("A1").Activate Worksheets(wsName).QueryTables(qtname).Refresh BackgroundQuery:=False Next qt Next ws |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Loop type formula - no Macro | Excel Discussion (Misc queries) | |||
Help: Compile error: type mismatch: array or user defined type expected | Excel Programming | |||
Help - Type mismatch when running loop with strings from arrays | Excel Programming | |||
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error | Excel Programming | |||
Copying data to another worksheet gives "Type Mismatch" error | Excel Programming |