+ Reply to Thread
Results 1 to 11 of 11

Adding a button to find string in column and fill out the first empty cell

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    13

    Adding a button to find string in column and fill out the first empty cell

    Hey there,
    I'm trying to create a button that would do a string search through Column A (task serial numbers) to determine the next task serial number and insert it into the first empty cell in the column. An example of the column is shown below:

    Column A
    1 Task#
    2 12-1
    3 12-2
    4 12-3
    5 12-4
    6 10-1
    7 10-2
    8 10-3
    9 11-1

    The number to the left of the hyphen stands for the year and the number to the right of the hyphen stands for the task number for that year. So for any additional tasks assigned this year, the serial number has to start with 12 and the number after the hyphen has to be 1 higher than the previous task. In case of the example above, clicking on the button should insert "12-5" into cell A10. If there hasn't been any tasks assigned for this year (no 12 in front of hyphen), then clicking the button should add the first task serial number (12-1) for 2012 in A10. I'm sure it's a simple solution but I just cannot figure out as I'm still a newbie to VBA. I'd appreciate any help on this. The codes I have been playing with:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Adding a button to find string in column and fill out the first empty cell

    vaznlyfe,

    Give this a try:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    08-16-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Adding a button to find string in column and fill out the first empty cell

    Wow tigeravatar, you are awesome. That's exactly what I need. Thanks alot!

  4. #4
    Registered User
    Join Date
    08-16-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Adding a button to find string in column and fill out the first empty cell

    After filling out the task serial number, is it possible to get excel to automatically fill in the person's name (displayed in Sheet tab) the next cell over, and then scroll to and select the description cell (3rd cell over) so the person can fill in his/her task description? Thanks.

    Task # Person Assigned Task Description
    12-5 John Create task list
    12-6 John Create VBA
    12-7 John |

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Adding a button to find string in column and fill out the first empty cell

    vaznlyfe,

    Yes, that is possible. How does Excel know which name to choose though?

  6. #6
    Registered User
    Join Date
    08-16-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Adding a button to find string in column and fill out the first empty cell

    Can it pull the name from the name of the active sheet?
    Last edited by Cutter; 08-27-2012 at 03:02 PM. Reason: Removed whole post quote

  7. #7
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Adding a button to find string in column and fill out the first empty cell

    Ooh, ok. So the worksheet is named "John". Yeah, give this code a try. Note that it has an input box prompting for the description.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-16-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Adding a button to find string in column and fill out the first empty cell

    Everything is good except I dont need the inputbox. Regardless of where I'm at in the excel sheet, when I click that button I just need for the screen to scroll to that row (maybe have the row in the center of the screen?) and double clicked on the task description cell so that it is ready for user input.
    Last edited by vaznlyfe; 08-27-2012 at 03:24 PM.

  9. #9
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Adding a button to find string in column and fill out the first empty cell

    Updated code:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-16-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Adding a button to find string in column and fill out the first empty cell

    Once again, you came to the rescue. Thank you so much.

  11. #11
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Adding a button to find string in column and fill out the first empty cell

    You're very welcome

    If that takes care of your need, please mark this thread as solved.
    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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