Results 1 to 48 of 48

Calculate the Date of an Item Based on the Date of a Similar Item in the Previous Month

Threaded View

  1. #11
    Registered User
    Join Date
    12-21-2017
    Location
    Wokingham, England
    MS-Off Ver
    office 365 2013
    Posts
    46

    Re: Calculate the Date of an Item Based on the Date of a Similar Item in the Previous Mont

    Thank you for you friendly and helpful reply NOT! A little toleration in your response would have been nice.

    What do you mean by
    Moved from Excel Formulas & Functions
    ? Where has it been moved to or has it been removed altogether?

    I had major problems navigating the rather convoluted process of entering code and attaching the example file and made a number of attempts at posting my update; losing my content several times. I even posted a query with the webmaster. The forum format and navigation, not to mention some moderators, is not very friendly to occasional users.

    The final post was made by accident and I was so relieved at getting something to stick that actually had retained the attached file that I failed to notice that the code was not enclosed by code tags. Here it is again, enclosed by tags:

    Function FindReceiptDate(CurrReceiptDate As Integer)
    
    'This function sets up the entries for the receipts on each worksheet by:
    '1)   Checking for five Fridays in the active workksheet.
    '2)   Checking for the presence of a receipt in the active worksheet.
    '3)   If the worksheet is Apr then uses a seed date obtained manually from the last receipt from the workbook for the previous year (Mar).
    '4)   For subsequent worksheets it finds the date (day only as an integer) of the (last) receipt for the previous month.
    '5)   It then adds 28 days to obtain the receipt date for the current worksheet.
    '6)   If the date is less than 28 days before the end of the month it finds the date of a second receipt for the current month.
    '7)   It finally populates the rest of the record.
    'A future development may be the automatic population of receipts on every sheet.
    
    Const Receipt = "Receipt"
    Dim CurrSheetNumber As Integer
    Dim PrevSheetNumber As Integer
    'Dim CurrReceiptDate As Integer
    Dim PrevReceiptDate As Integer
    Dim SecondReceiptDate As Integer
    Dim CurrDays As Integer
    Dim PrevDays As Integer
    
    CurrSheetNumber = ActiveSheet.Index
    PrevSheetNumber = ActiveSheet.Index - 1
    
    PrevDays = Day(Application.WorksheetFunction.EoMonth(Range("$B$4"), -1))   'Days in previous month
    CurrDays = Day(Application.WorksheetFunction.EoMonth(Range("$B$4"), 0))   'Days in current month
    
    '1) Find the date of the AA receipt for the current month based on teh receipt date of the previous month (+28 days).
    '2) Check to see if there are two payment in the current month.
    
    If PrevSheetNumber <> 0 Then
       Worksheets(PrevSheetNumber).Select
          Range("F5:F49").Find(Receipt).Select
       PrevReceiptDate = Cells(ActiveCell.Row, 3)
       CurrReceiptDate = PrevReceiptDate + 28 - PrevDays
       Worksheets(CurrSheetNumber).Select
    '   MsgBox "AA Receipt date this month = " & CurrAAReceiptDate
    '   If CurrAAReceiptDate + 28 <= CurrDays Then
    '      SecondAAReceiptDate = CurrAAReceiptDate + 28
    '      MsgBox SecondAAReceiptDate
    '   End If
       
    End If
    
    FindFirstEmptycel = CurrReceiptDate
    
    'Range(ActiveCell).value = CurrAAReceiptDate
    'MsgBox (ActiveSheet.Name)
    'MsgBox ("Days last month=" & PrevDays & "  Days this month = " & CurrDays)
    'MsgBox "AA Receipt date last month = " & PrevAAReceiptDate
    
    
    End Function
    Edit
    Further inspection suggests that I had enclosed the code in code tags. In this post, in which the code definitely was enclosed in tags, the code is displayed in a panel with a grey background and with a "Copy to clipboard" icon identical to my previous post. On what have you based your criticism?
    Last edited by Tegglet; 09-10-2021 at 01:00 PM. Reason: Additional comments

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Index match date, receipt number, invoice number and amount from 3 worksheets
    By sunboy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-16-2020, 12:16 PM
  2. Formula To Calculate Month in a Previous Date
    By breader21 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-07-2020, 10:44 PM
  3. Replies: 13
    Last Post: 11-22-2019, 08:27 PM
  4. [SOLVED] Actual Receipt Date Vs. Original Receipt Date (Compare & Provide Result)
    By Rajeshkumar R in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-05-2018, 07:06 AM
  5. Replies: 5
    Last Post: 02-06-2013, 02:11 PM
  6. Date of Receipt based on In/OUT
    By cmcconna in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2010, 06:47 PM
  7. Auto calculate end date of previous month
    By BusterBoy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-28-2009, 07:57 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