run-time error 1004

P

petyrc

Hoping someone can help me out. I have no knowledge of VB so this is
all greek to me. Below is one of seven macro that runs to a report that
is integrated into a CRM database (salesfoece.com). I get this error
when I try to run the macro that refreshes the data being pulled from
salesforce.com into the report. I get the error message "run-time error
1004" and it highlights the following text in
yellow....Selection.QueryTable.Refresh BackgroundQuery:=False
right above this text...

' Refresh Data
Sheets("Raw Data").Select
Range("AI28").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("BH33").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("Reference").Select
Range("B26").Select

QUESTIONs:
What does "Selection.QueryTable.Refresh BackgroundQuery:=False" mean?
What does Range(BH33) mean?
How might I fix this busted macro?

thanks in advance for your help
p


COMPLETE VB SCRIPT FROM BUSTED MACRO

Sub Sort_Refresh()
'
' SOrt_Refresh Macro
' Macro recorded 11/10/2005 by tchan
'


' Clear Top 100, Raw Data sheets
Sheets("TOP 100").Select
Cells.Select
Selection.ClearContents
Sheets("Raw Data").Select
Columns("A:Y").Select
Range("Y1").Activate
Selection.ClearContents

' Refresh Data
Sheets("Raw Data").Select
Range("AI28").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("BH33").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("Reference").Select
Range("B26").Select
Selection.QueryTable.Refresh BackgroundQuery:=False

' Sort to determine duplicates
Sheets("Raw Data").Select
Columns("BA:BP").Select
Range("BP1").Activate
Selection.Sort Key1:=Range("BA2"), Order1:=xlDescending,
Key2:=Range( _
"BB2"), Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
_
DataOption2:=xlSortNormal
Columns("AA:AP").Select
Range("AP1").Activate
Selection.Sort Key1:=Range("AA2"), Order1:=xlDescending,
Key2:=Range( _
"AB2"), Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
_
DataOption2:=xlSortNormal

' Replace Enterprise Based Support with EBS
Columns("BE:BE").Select
Selection.Replace What:="Enterprise Based Support",
Replacement:="EBS", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:= _
False, ReplaceFormat:=False

' Time Stamp
Sheets("Reference").Select
Range("H3").Select
Selection.COPY
Sheets("Instructions").Select
Range("I6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "[$-409]m/d/yy h:mm AM/PM;@"

'Ready Message
If Application.Ready = True Then
MsgBox "Application is ready."
Else
MsgBox "Application is not ready."
End If

End Sub
 
S

Snake Plissken

QUESTIONs:
What does "Selection.QueryTable.Refresh BackgroundQuery:=False" mean?

it causes previously set querytable (within "Raw Data" sheet) to refresh
(connection to database based on query definition, retrieving data )
What does Range(BH33) mean?

the place in sheet "Raw Data" where querytable begins
How might I fix this busted macro?


IMHO macro is not a problem in this case - maybe you cleared contents (part
of sheet area) of "Raw Data" manually so querytable is not existing anymore
in indicated range "BH33" or maybe conection ( or database statement ) to
particular database fails.
If you have a copy of this file - check it out - maybe it will work.
 

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