+ Reply to Thread
Results 1 to 1 of 1

Create matrix from a "table" by condition on lacking date-value

Hybrid View

  1. #1
    Registered User
    Join Date
    01-13-2011
    Location
    scandinavia
    MS-Off Ver
    Excel 2007
    Posts
    27

    Create matrix from a "table" by condition on lacking date-value

    Hi,

    I have a VB-challenge in making a code that runs through a kind of table in sheet1 which is queried by SQL/ADO and check for each ID (col A) or NAME (col B) what the last update date is (col C), - if the last update date is older than before yesterday (let's say yesterday is always 26-07-2011 for testing purpose) then this ID and NAME should be brought to a new table/matrix which its rows labels are the ID and NAME and column labels are the color in which the ID and NAME is contained, - and in the matrix itself should be stated how many days the update is lacking, eg if eddy has last update date 24-07-2011, then -2 should appear in the corresponding matrix-field.

    Look at my workbook for a much easier explanation.


    Sub portefølgemangler()
    
    Dim lastdate As Variant
    Dim daterng As Range
    Dim j As Variant
    
    Set daterng = Worksheets("Sheet1").Range("c6:c")
    
    For Each lastdate In daterng
    If CDate(lastdate) <= CDate((Date - 2)) Then 'note that Date returns today's date but in my case and for testing purposes, we let this date be 27-07-2011
    Worksheets("Sheet1").Cells(22, 7) = Worksheets("Sheet1").Cells(lastdate.rowindex, 2)
    End If
    Next lastdate
    
    End Sub
    The code contains error, especially the lastdate.rowindex --i don't think it works.
    My challenge is indeed the loop where every time there has been a too old date for an ID/NAME and this ID/name get listed then the next record for the next ID/NAME which is too old should appear below the one earlier untill there's no more old dates (the rowindex in .cells(j,7) should vary)...You understand what i mean if you open the file. Note that it's not static table in sheet1..it gets updated so every time an update of the table takes place, i should run the vb-code and then the lacks-matrix should be updated accordingly.

    Thanks for any help in advance!
    Attached Files Attached Files

+ 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