LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default Query does not seem to work...

I just have a quick Visual Basic question about Formula R1C1... I've
incorporated into my query code... The Code is as follows;

Sub Button9_Click()
' Cost Element Button

'This part of the code clears the other filters
Worksheets("WBS Query").Range("B4,E6,G4,J4,M4").ClearContents



Sheets("WBS DATA").Select

Range("R2").Select
ActiveCell.FormulaR1C1 = "4100"



'This part of the code Copies and pastes the criteria
Worksheets("WBS Data").Range("Q2:T2").Copy
ActiveSheet.Paste Destination:=Worksheets("WBS Data").Range("Q3:T3")

Set Company = Worksheets("WBS Data").Range("R1")
Set Query = Worksheets("WBS Data").Range("WBS_Charges")
Set Criteria = Sheets("WBS Data").Range("r1:R2")

Worksheets("WBS Data").Range("R1").Calculate
Query.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Criteria, _
CopyToRange:=Range("A11:M11"), Unique:=False

'This part of the code copies Q3:T3, pastes it back to Q2:T2 and deletes Q3:T3
Worksheets("WBS Data").Range("Q3:T3").Copy
ActiveSheet.Paste Destination:=Worksheets("WBS Data").Range("Q2:T2")
Worksheets("WBS Data").Range("Q3:T3").Clear

End Sub

If I manually enter 4100 into cell R2 it will query the database... It will
also work if I let the code put it in, but not run the query, then block out;

'Sheets("WBS DATA").Select

' Range("R2").Select
' ActiveCell.FormulaR1C1 = "4100"
then run the query...

But if I let the all the code run, it gives me "Run time error "1004", The
extract name has a missinng or illegal field name...

Any help would be greatly appreciated,

Thanks,
Kevin...
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use MS Query to query data within the current work book Steve Kesler Excel Discussion (Misc queries) 0 August 6th 09 05:22 PM
Excel Query Does not Work [email protected] New Users to Excel 1 January 28th 07 06:30 AM
web query on EXCEL does not work. Why? jimf Excel Discussion (Misc queries) 1 January 4th 06 05:09 AM
web query doesn't work Brian Allen Excel Discussion (Misc queries) 0 November 17th 05 11:51 AM
Can't get Web Query to work [email protected] Excel Programming 1 April 7th 04 05:39 PM


All times are GMT +1. The time now is 09:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"