+ Reply to Thread
Results 1 to 4 of 4

Yahoo Finance - Need a Macro to Delete Cell and Shift Cells up

Hybrid View

  1. #1
    Registered User
    Join Date
    12-06-2015
    Location
    Sao Paulo, Brazil
    MS-Off Ver
    2010
    Posts
    3

    Yahoo Finance - Need a Macro to Delete Cell and Shift Cells up

    First and foremost, I know nothing about Macros (setting them up, writing them, etc.), so if you respond you're basically responding to an idiot. That being said, after doing some reading, I'm fairly sure a Macro is what I'm looking for.

    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.

    For the tests I'm trying to run, it's imperative that the dates for the ETF and Index data match. 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.

    Here's a link to the file on Google Drive should anyone like to see it.
    Last edited by dabears19850; 12-06-2015 at 09:01 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Yahoo Finance - Need a Macro to Delete Cell and Shift Cells up

    Sub delDiv()
    Dim sh As Worksheet, i As Long, lr As Long
    Set sh = ActiveSheet 'If sheet is always same name, use Sheets("<Sheet name>") here
    lr = sh.Cells(Rows.Count, "G").End(xlUp).Row
        For i = lr To 2 Step -1
            If InStr(sh.Cells(i, 7).Value, "Dividend") > 0 Then
                Rows(i).Delete xlShiftUp
            End If
        Next
    End Sub

  3. #3
    Registered User
    Join Date
    12-06-2015
    Location
    Sao Paulo, Brazil
    MS-Off Ver
    2010
    Posts
    3

    Re: Yahoo Finance - Need a Macro to Delete Cell and Shift Cells up

    I've had some success this evening. 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:

    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
    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.

  4. #4
    Registered User
    Join Date
    12-06-2015
    Location
    Sao Paulo, Brazil
    MS-Off Ver
    2010
    Posts
    3

    Re: Yahoo Finance - Need a Macro to Delete Cell and Shift Cells up

    Bump. Still looking for help should someone feel compelled.
    Last edited by dabears19850; 12-08-2015 at 07:44 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Yahoo Finance
    By kanee_2010 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-25-2015, 12:47 PM
  2. [SOLVED] Delete cells when value in cell = 0 and shift up following cells (macro)
    By sandi3006 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-10-2014, 10:24 AM
  3. Getting real time stock quotes from google finance / yahoo finance in excel
    By Navin Agrawal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2012, 12:41 PM
  4. yahoo finance into excel macro
    By losmi8 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-06-2009, 06:18 PM
  5. Web Query with Yahoo Finance
    By horton123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2009, 02:26 AM
  6. Web Query : Yahoo finance
    By schnett in forum Excel General
    Replies: 0
    Last Post: 11-25-2007, 03:24 PM
  7. Macro - asked username & password and sign into Yahoo Finance
    By cbnowhere in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-02-2006, 04:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1