+ Reply to Thread
Results 1 to 10 of 10

Auto-fill cells depending on input

  1. #1
    Registered User
    Join Date
    02-24-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    11

    Auto-fill cells depending on input

    Hello,

    I am trying to have cells auto-filled depending on the input, I attached an example of the format I'm looking at.
    I previously was able to do this with regular functions, however, now there would be a number stating how many times the cells need to be repeated.

    I have attached an example Excel with the data format. I split it in 2 tabs to make clear what input and what output would be.

    Here, Column A-D would be a text string, and E on the input tab as a number, noting how many times A-D should be repeated.

    I'm struggling with linking the number of repeats to the output, without "replacing" lines.

    If you could push me in the right thinking path already that would be great!

    (Is this even possible)

    Thank a lot in advance,
    Kobe
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Auto-fill cells depending on input

    Hi and welcome to the forum

    Here's one macro. Adapt the Sheet1 VBA code name and the column A identifier as necessary

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Auto-fill cells depending on input

    Here is another macro (non-looping) that you can try... run it with your data sheet active (I can modify the code if you will need to run it with a different sheet active)
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Auto-fill cells depending on input

    Quote Originally Posted by Rick Rothstein View Post
    Here is another macro (non-looping) that you can try... run it with your data sheet active (I can modify the code if you will need to run it with a different sheet active)
    .......Neat!

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Auto-fill cells depending on input

    Quote Originally Posted by Richard Buttrey View Post
    .......Neat!
    Nope! As it turns out, my code appears not to be neat at all... because it doesn't work correctly (anymore). I tested it before I posted it and I could swear it worked correctly... then, but in testing it again on a brand new workbook it no longer is working correctly. I am not sure what went wrong... yet, but I'll figure it out (hopefully) and post back with corrected code once I have done so. In the meantime, ignore the code in Message #3!!!

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Auto-fill cells depending on input

    Okay, I figured it out. While I was at it, I made it so the last column can be anything the programmer specifies... all they have to do is assign the column letter designation for the last column to the LastCol variable.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-24-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    11

    Re: Auto-fill cells depending on input

    Thanks Rick, this code works brilliantly!

    Just to understand how this work, how do I define the starting position? Let's say that instead of Row 2 I want it to start from row 3

  8. #8
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Auto-fill cells depending on input

    Here is my code modified to start on Row 3 (I highlighted all of the changes in red)...
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-24-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    11

    Re: Auto-fill cells depending on input

    Thanks a lot Rick, this really helped me out, probably saving 100s of hours in the long run :-)

  10. #10
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Auto-fill cells depending on input

    You are quite welcome. Since I have seen questions like yours in the past, I will probably see them in the future as well, so I decided to completely generalize my code... this makes some of the code lines longer (maybe I should have used shorter variable names), but I think the trade off is worth it. With this new code, you will be able to assign all parameters using variables at the beginning, that way you will not have to try and find all of the pieces to change should your needs change in the future.
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 09-11-2019 at 10:58 AM.

+ 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. Auto fill cells depending on value of cell X
    By kevinwuyts in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-07-2019, 10:09 AM
  2. Replies: 6
    Last Post: 10-06-2018, 01:15 PM
  3. Auto-fill dates based on input in other cells
    By bwill225 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-28-2018, 07:43 AM
  4. Help with auto fill cells based on two cell input.
    By Osros in forum Excel General
    Replies: 0
    Last Post: 07-07-2014, 07:30 PM
  5. [SOLVED] Background fill RGB color depending on the 3 input cells R,G and B?
    By Chebu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2013, 07:46 AM
  6. Auto fill cells depending on Drop down List selection
    By Trengor in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-22-2008, 11:06 AM
  7. Auto fill multiple cells depending on single cell value
    By henrat in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-28-2005, 01:10 AM

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