View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] subirias.s3@gmail.com is offline
external usenet poster
 
Posts: 3
Default Run-time error "5" after range().delete runs before querytable.add

#1 I'm not a programmer, just learning this stuff so please excuse the
"stupid" questions. Pleae explain the reason or fix in plain english
so I can understand and learn from this.

I'm pulling data from from the internet using the following WEBQUERY:
as a gosub routine. It works perfectly every single time! But when I
add either of the two following commands, I get the runtime error "5"
error.

pgname.Range("A1:R100").Delete (xlShiftUp)
pgname.Range("A1:R100").Delete

When I remove the code the WEBQUERY: works fine without a hitch.
Please help me i) understand why this is causing a problem and ii) how
can I get the specified range cleared before the WEBQUERY: routine
runs. By the way, the

...... broken code excerpt .....
WEBQUERY:
pgname.Range("A1:R100").Delete (xlShiftUp) '<-- executes!
With pgname.QueryTables.Add(Connection:= _ '<-- errors!
"URL;" & mwURL & scantype & "" _
, Destination:=rng)
.Name = scantype
...
..