+ Reply to Thread
Results 1 to 9 of 9

Need a macro to add 1 to active cell based on previous cell contents

  1. #1
    Registered User
    Join Date
    10-19-2014
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    3

    Need a macro to add 1 to active cell based on previous cell contents

    Hi All,

    I am VERY inexperienced with VBA, but I do like to dabble.

    I would like to have a macro (called "Add New Quote Number"), and have it do the following...

    I press the macro button

    It looks for the end of the column (B) - I know this code [Range("b65536").End(xlUp).Offset(1).Select]

    This may end up at B91 whose content might be "Quote Number 091" for example.

    I need B92 to equal "Quote Number 092" (based on B91 + 1)

    I hope this makes sense, and I thank you all in advance for your assistance.

    Cheers

    WTOM

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Need a macro to add 1 to active cell based on previous cell contents

    what your asking sounds very familiar to this question posed
    http://www.excelforum.com/excel-prog...invoicing.html

    if that doesn't answer your question please provide sample file for inputs and outputs look like
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,035

    Re: Need a macro to add 1 to active cell based on previous cell contents

    try this:

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Need a macro to add 1 to active cell based on previous cell contents

    slightly different because of quote number
    Please Login or Register  to view this content.
    Last edited by humdingaling; 10-19-2014 at 11:17 PM. Reason: added format for 3 digits

  5. #5
    Registered User
    Join Date
    10-19-2014
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    3

    Re: Need a macro to add 1 to active cell based on previous cell contents

    Hi humdingaling, that works well, except for the text "Quote Number". I need the macro to copy the above cells text as it appears then +1 to it.

    The text part will differ yearly.

    For example, this year, the quote number format is "RCH-15-xxxx", (where "RCH" relates to the business unit, "15" relates to the current financial year, and "xxxx" relates to the incrementing four digit quote number. Next year it will be "RCH-16-xxxx" with "16" denoting the next fin year.

    So, if the text in cell B23 is currently "RCH-15-0145" and it is at the end if the column, after the macro runs, B24 would become "RCH-15-0146", and so each time the macro is invoked.

    I hope that makes sense?


    Cheers

    WT

  6. #6
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Need a macro to add 1 to active cell based on previous cell contents

    Ok then Try this..
    Please Login or Register  to view this content.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  7. #7
    Registered User
    Join Date
    10-19-2014
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    3

    Re: Need a macro to add 1 to active cell based on previous cell contents

    Perfect Vikas, thank you so much!!

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Need a macro to add 1 to active cell based on previous cell contents

    Hi,

    I still wonder why people indicating to use a version of 2007 or greater use the limitation of pre 2007 files.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  9. #9
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Need a macro to add 1 to active cell based on previous cell contents

    Thanks for the response WTOM
    However, Holgers approach is more good too..

+ 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. Populate Data based on Previous cell contents
    By rkb in forum Excel General
    Replies: 1
    Last Post: 12-02-2010, 07:16 AM
  2. Populate Data based on Previous cell contents
    By rkb in forum Excel General
    Replies: 1
    Last Post: 12-02-2010, 06:17 AM
  3. Replies: 4
    Last Post: 06-04-2009, 04:56 AM
  4. Working out an average based on a previous cell contents
    By panther_sn in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-08-2008, 09:11 AM
  5. Macro to paste in the active cell the contents of a cell from another file??
    By LarryB in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2006, 01:45 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