+ Reply to Thread
Results 1 to 3 of 3

Find gaps in stock data

Hybrid View

  1. #1
    Registered User
    Join Date
    02-12-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007, 2013
    Posts
    89

    Find gaps in stock data

    I am in need of a simple macro to find gaps in stock data. I've attached a dummy workbook with further detail. Would appreciate if anyone could help. Thanks
    Attached Files Attached Files
    Last edited by Test123Test; 03-18-2012 at 01:39 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Find gaps in stock data

    see the result of the macro in column sV and W.
    data in col S and T kept for checking. you can delete them

    I am also sending back the file

    the macro (already in the module of this file)


    Sub test()
        Dim r As Range, c As Range
        Dim cclose As Double, oopen As Double, dest As Range
        Columns("V:w").Delete
        Set r = Range(Range("A5"), Range("A5").End(xlDown).Offset(-1, 0))
    
    
        For Each c In r
            If c <> c.Offset(1, 0) Then
                cclose = Cells(c.Row, "F").Value
                oopen = Cells(c.Offset(1, 0).Row, "C").Value
    
                Set dest = Cells(Rows.Count, "V").End(xlUp).Offset(1, 0)
                dest = c.Offset(1, 0).Value
                dest.Offset(0, 1) = oopen - cclose
            End If
        Next c
        Range(Range("V2"), Range("V2").End(xlDown).Offset(0, 1)).Cut Range("V6")
    End Sub
    the data after running macro will be
    Attached Files Attached Files
    I am not an expert. better solutions may be available
    $$$$venkat1926$$$$@gmail.com

  3. #3
    Registered User
    Join Date
    02-12-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007, 2013
    Posts
    89

    Re: Find gaps in stock data

    venkat1926, this code works perfect! thanks so much, repped and marked thread as solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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