Results 1 to 10 of 10

Thread: $15 To Amend Macro To Find The Next Available Earlier Or Previous Date

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    9
    Rep Power
    0

    $15 To Amend Macro To Find The Next Available Earlier Or Previous Date

    Hi,

    I have a workbook with a few hundred tabs on it (one for each of our customers)

    Basically each one is a for a pot of money by which they can order stock from us and can increase from time to time according to their agreement with us.

    I need to be able to report what the balance of each customers fund is on any given date.

    I have the following macro which searches for the date and returns the figures on the summary page.

    Code:
    Option Explicit
    
    Sub Summary()
        Dim w As Worksheet
        Dim i As Long
        'Dim rng As Range
        Dim d As Date
        Dim lrng As Range
        Dim lr As Long
        d = InputBox("What Date to Search")
        'Dim wsFunc As WorksheetFunction
        'Set wsFunc = Application.WorksheetFunction
        
    
        For Each w In Worksheets
            If w.Name <> "Summary" Then
            'Set rng = w.Range("L6:L" & Range("L" & Rows.Count).End(xlUp).Row)
            Set lrng = w.Range("L:M")
            lr = Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Row
            
                For i = 6 To w.Range("L" & Rows.Count).End(xlUp).Row
                    On Error Resume Next
                    'If w.Range("L" & i) = wsFunc.VLookup(d, lrng, 2, False) Then
                    If w.Range("L" & i) = d Then
                    w.Range("L" & i).Resize(, 2).Copy
                    Sheets("Summary").Range("B" & lr + 1).PasteSpecial Paste:=xlValues
                    Sheets("Summary").Range("A" & lr + 1) = w.Name
                    End If
                Next i
            End If
        Next w
        MsgBox ("Complete")
    
    End Sub
    The issue I have is that there will be customers with no orders on the specified date, therefore I need it to return the figure for the next available previous date.

    Thanks in advance.
    Attached Files Attached Files
    Last edited by Admin; 04-15-2014 at 09:38 PM.

Similar Threads

  1. Find the value of the due date falls between two dates
    By mahmoud-lee in forum Excel Help
    Replies: 2
    Last Post: 03-14-2014, 10:48 AM
  2. Replies: 7
    Last Post: 03-11-2014, 05:38 PM
  3. Macro stops running if date is not in past...
    By Carlos Arruda in forum Excel Help
    Replies: 4
    Last Post: 03-10-2013, 04:33 PM
  4. How to Lock or Unlock row basis previous cell input?
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 2
    Last Post: 07-25-2012, 02:40 PM
  5. Find Quarter Month From Date In Excel
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 15
    Last Post: 04-19-2012, 02:08 PM

Posting Permissions

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