macro to delete specific row with queries embedded

M

Mervyn

Hi everyone

im trying to compile a excel sheet that retrieves data from yahoo
finance
i made 12 web queries (each one has 66 rows of data),each one for a
different page of data for the same company stock
and i adjusted the query to refresh for query 1 (row 1 -66) ,query 2
(row 67-133)...and so on

i also placed a macro to delete rows that have 0 data or have words as
data
but somehow executing the macro deletes the row as well as the embedded
webquery in the sheet
and if i refresh the query again ,the data is messed up,much shorter
than before as compered with if i dont delete .

Please advise me on how to tweak this as it is pretty urgent (need it
by next week)
if u want i can send u the excel file to check
Thank you so much

Regards
Mervyn





macro is as below

Sub aaacut()
'
' aaacut Macro
' Macro recorded 07/11/2006 by Mervyn Teo
'
Call DeleteRows
End Sub

'
Public Sub DeleteRows()


Dim R As Long
Dim C As Range
Dim Rng As Range


On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual


If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
For R = Rng.Rows.Count To 1 Step -1
If Cells(R, "C").Value = "" Then
Rng.Rows(R).EntireRow.Delete
ElseIf Cells(R, "C").Value = "High" Then
Rng.Rows(R).EntireRow.Delete
End If
Next R


EndMacro:


Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic


End Sub
 

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