+ Reply to Thread
Results 1 to 10 of 10

VBA to add constant value to cell if a date is input into another.

  1. #1
    Forum Contributor
    Join Date
    03-02-2010
    Location
    Northumberland, England
    MS-Off Ver
    Excel 2016
    Posts
    143

    VBA to add constant value to cell if a date is input into another.

    Hello,

    I would like to add a constant value of 20160 in column M of my spreadsheet based on a date being input in column I

    The rows start at 6 and go on until 5000

    Can anyone offer me the right doe that will allow this. I tried using formula but Im running other code that looks at each row and it didnt like the formula being there. Or any other solution would be great.

    BF
    Last edited by singerbatfink; 02-16-2016 at 08:16 AM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to add constant value to cell if a date is input into another.

    Put this event code in the relevant sheet module:

    Please Login or Register  to view this content.
    Directions for running the routine(s) just supplied

    If you haven't used macros before you'll need to go to:
    File- options - trust center -trust center settings - macro settings ,
    the second option down (disable all macros with notification)
    '[email protected]
    Then - Copy the code to the clipboard

    Open your Workbook

    Press ALT + F11 to open the Visual Basic Editor.

    Click on your sheet

    Type "Option Explicit" then paste the code under it

    And you're set to go!
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    03-02-2010
    Location
    Northumberland, England
    MS-Off Ver
    Excel 2016
    Posts
    143

    Re: VBA to add constant value to cell if a date is input into another.

    Thanks xladept, thets great. When I clear the date in column I the values 20160 still remains, I'd like it to return to a blank cell. Can you help?

    BF
    Last edited by singerbatfink; 02-11-2016 at 06:00 AM.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to add constant value to cell if a date is input into another.

    Try this:

    Please Login or Register  to view this content.
    And let me know

  5. #5
    Forum Contributor
    Join Date
    03-02-2010
    Location
    Northumberland, England
    MS-Off Ver
    Excel 2016
    Posts
    143

    Re: VBA to add constant value to cell if a date is input into another.

    Hi, again thanks for your reply but the 20160 still remains when the date is deleted.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,164

    Re: VBA to add constant value to cell if a date is input into another.

    Hi,

    See if this does what you need.
    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to add constant value to cell if a date is input into another.

    I broke down and tested it - here's my corrected code:

    Please Login or Register  to view this content.
    Last edited by xladept; 02-12-2016 at 01:38 PM.

  8. #8
    Forum Contributor
    Join Date
    03-02-2010
    Location
    Northumberland, England
    MS-Off Ver
    Excel 2016
    Posts
    143

    Re: VBA to add constant value to cell if a date is input into another.

    Thanks xladept and MarvinP

    Ive give them both a try

  9. #9
    Forum Contributor
    Join Date
    03-02-2010
    Location
    Northumberland, England
    MS-Off Ver
    Excel 2016
    Posts
    143

    Re: VBA to add constant value to cell if a date is input into another.

    This eventually did the trick,

    Please Login or Register  to view this content.

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to add constant value to cell if a date is input into another.

    You're welcome and thanks for the rep!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Input date in cell based on another cell without updating the date
    By gaker10 in forum Excel General
    Replies: 5
    Last Post: 01-08-2015, 04:51 PM
  2. Replies: 1
    Last Post: 09-18-2013, 01:58 PM
  3. [SOLVED] Prompt input of future date in cell when another cell has been populated or modified
    By coffeemints in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2013, 06:46 PM
  4. Input date, click CommandButton, new date appears in the following cell
    By adamj1910 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2012, 10:59 AM
  5. [SOLVED] input date column A, increment B, select blank cell in D and input time. in a macro
    By jeffstu in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2012, 11:19 AM
  6. [SOLVED] Date Filter based on Cell Input - single date or range of dates
    By babaloo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2012, 10:32 AM
  7. User input Auto multiplies by constant
    By vikhound in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-01-2009, 02:32 PM

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