+ Reply to Thread
Results 1 to 9 of 9

Select cell based on first of month date

  1. #1
    Registered User
    Join Date
    04-04-2011
    Location
    New Jersey, US
    MS-Off Ver
    2010
    Posts
    18

    Select cell based on first of month date

    I have a range of dates in column B of my spreadsheet. I have the Today() function in E2. I would like to know how to use vba so that when it is the first of the month in E2, a function will run that will clear 6 cells to the right of that date, and run before any values are entered into E3:E5. After the initial clear, I would like for it to be able to take input from E5:E6. Thanks for any assistance, Mike.
    Attached Files Attached Files
    Last edited by mexcel300; 04-16-2011 at 06:17 PM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Select cell based on first of month date

    hi, Mike, please check attachment
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-04-2011
    Location
    New Jersey, US
    MS-Off Ver
    2010
    Posts
    18

    Re: Select cell based on first of month date

    Hi watersev, thanks for the input, however, it doesn't let me enter values on the row for the first date using the input form. It seems to add numbers correctly after that row, i.e. 4/2/11 but not on the 1st of the month row. I want it to clear the numbers on the first day because the way the sheet is setup, the numbers sum down continuously and that row(4/1/11) will have March's total in there so I won't be getting an accurate sum of what is spent each month. I want to start with fresh numbers each month. Hope this makes sense.

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Select cell based on first of month date

    check attachment, the code will only clear off 6 cells to the right of the first month date cell. Then you can add data through the add button.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-04-2011
    Location
    New Jersey, US
    MS-Off Ver
    2010
    Posts
    18

    Re: Select cell based on first of month date

    Checked it out. It clears the cells but it is still taking the totals from D18,F18, and H18 and putting them into D19, F19, and H19. It is those particular columns that have the running totals for each expenditure that need to be cleared, and somehow stay cleared after data is input in the form on the 1st day of the month so that it starts a new running total each month. The main idea is that I would like to have totals just for the particular month at the end of each month. Maybe the idea I have isn't the best approach so I'm open to suggestions to accomplish that. Thanks for the continued help watersev.

  6. #6
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Select cell based on first of month date

    please check attachment, on the first day of each month it will start summing up values from zero
    Attached Files Attached Files
    Last edited by watersev; 04-16-2011 at 06:41 AM.

  7. #7
    Registered User
    Join Date
    04-04-2011
    Location
    New Jersey, US
    MS-Off Ver
    2010
    Posts
    18

    Re: Select cell based on first of month date

    That seems to remedy the change of the month, but now when I go to enter numbers from the month before, for example March 31 and add them in, I get a runtime 91 error object variable or with block variable not set. If I was on say April 5th, but forgot to record an entry for March 31st, would it be possible to add a value for a previous month or is that getting too complex?

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Select cell based on first of month date

    yes, you get that error because column B has no 1 of March date. If all the dates are in chronological order there will be no mistake.
    How the code works: it checks for the row where 1 day of the month of E2 is located and uses that row for sum total. I can add error handler for this particular issue to make it more friendly.
    If all March dates are in column B you would not get error message.
    For this code to work column B must have 1st dates of all months you will enter data for.
    Last edited by watersev; 04-16-2011 at 12:04 PM.

  9. #9
    Registered User
    Join Date
    04-04-2011
    Location
    New Jersey, US
    MS-Off Ver
    2010
    Posts
    18

    Re: Select cell based on first of month date

    I will only use full months so don't worry about the error handler. I really appreciate your help with this. It gives me an idea on how vba works for some of these things as I am trying to learn the basics. Now I should be able to get this budget sheet functioning right. Thanks again watersev! Mike

+ 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