+ Reply to Thread
Results 1 to 4 of 4

VBA Code for Previous dates

  1. #1
    Registered User
    Join Date
    04-23-2012
    Location
    Davie, FL
    MS-Off Ver
    Excel 2013
    Posts
    83

    VBA Code for Previous dates

    Hello, I had created a forum question yesterday which worked with the VBA code someone gave me:


    Public Function PreviousDate(SearchRange As Range, CurrentDate As Variant) As Variant

    For Each c In SearchRange
    If c.Value < CurrentDate And c.Value > PreviousDate And c.Offset(0, -5) = "Active Client" Then
    PreviousDate = c.Value
    End If

    Next c

    End Function

    I had to create an array formula to another cell and now the code doesn't work anymore. Is there something i need to change to the code now so it will work again? Please help. See attached.
    Book4.xlsm

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: VBA Code for Previous dates

    HTML Code: 
    should be
    HTML Code: 

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: VBA Code for Previous dates

    this should work with any range, to use the search range and current date are the same, but the criteria range is the range of all criteria (in your workbook it is range F4:F42), criteria is either typed ie "Active Client" or a range F9

    criteria range can only be one column wide

    HTML Code: 

  4. #4
    Registered User
    Join Date
    04-23-2012
    Location
    Davie, FL
    MS-Off Ver
    Excel 2013
    Posts
    83

    Re: VBA Code for Previous dates

    Still didn't work..Not knowing how to work with Macros, makes this really difficult. Thanks anyway.

+ 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