Need a Macro to Delete Cell and Shift Cells up

dabears19850

New Member
Joined
Dec 7, 2015
Messages
4
So here's the situation... I've set up web queries for historical data from Yahoo Finance (so that way I can run automate updates on the data set). There's two web queries to upload two sets of data - 1 for the historical prices of an index, and the other for the historical prices of the ETF following that index. The data loads great and is aligned well EXCEPT for a small detail of the ETF data. The ETF data, in addition to loading the same exact date range as the Index, also downloads the dividend payout (while the index doesn't include that), so the dates no longer match going across the row (see image below).
Untitled.jpg



For the tests I'm trying to run, it's imperative that the dates for the ETF and Index data match by dates, which they will if I can remove that dividend line. Which leads me to what I'm looking for - a Macro capable of deleting/excluding only the cells containing the dividend payouts of the ETF that would then shift up the cells below it. I had some success last night. I got a Macro which will eliminate the dividend payout row I don't want, and shifts up all the data below it. However, I need to click it every time I want to remove that dividend payout row (and every time I refresh the web queries the dividend payout row reappears). For my case where I have LOT of data on multiple sheets and with frequent refreshes of the web queries it's not feasible to click the Macro function every time. Here's the Macro I currently have below:

Code:
<code>Sub Macro1()
'
' Macro1 Macro
'
'
    Cells.Find(What:="dividend", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
        Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(0, 5)).Select
    Selection.Delete Shift:=xlUp
End Sub</code>

How can I make this a one-click Macro (or even an automatic Macro) any time I need to refresh the data set?
I uploaded the spreadsheet to Google Drive should anyone like to download the current file.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,222,112
Messages
6,163,992
Members
451,867
Latest member
csktwyr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top