+ Reply to Thread
Results 1 to 8 of 8

Vba code to populate next open alternate rows from userform

  1. #1
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,231

    Vba code to populate next open alternate rows from userform

    Hi All

    I have submitted code that I have been trying to figure out for days with no luck.
    I have had variations of results but still none that meets the required result.

    My worksheets gets populated from a user form and I require the following:
    If Option Cheque is chosen from ComboBox2 then the first green row must be populated i.e. Row 3
    Thereafter each alternate green row must be populated i.e Row 5, 7, 9 etc
    If Option Cash is chosen from ComboBox2 then the first yellow row must be populated i.e. Row 4
    Thereafter each alternate yellow row must be populated i.e. Row 6, 8 ,10 etc

    Take note: Row 50 is a row containing formulas for totals Row 3 - 49.

    I thank you in advance for your expertise.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Vba code to populate next open alternate rows from userform

    You say the 1st Green or Yellow row depending on the value and then give examples of the row numbers, are these set in stone as such ie are green rows the odd ones and yellow the evens?

    if the first 5 entries are cheques then would you expect to see rows 3,5,7,9 and 11 populated? if the 6th is then Cash do you expect to populate 4 or 12? And Im going to be a pain and ask a newbie type question but is there a valid reason for these set rows? could you not just have an indicator that shows "Cheque" or "Cash" and then complete the rows as they happen? ie in the example above rows 3 - 7 would show Cheque and then 8 would contain the Cash item.

    Ideally, if you can upload your workbook that would help immensely.
    If someone has helped you then please add to their Reputation

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,231

    Re: Vba code to populate next open alternate rows from userform

    Hi PJ

    Thank you for your response.
    The green and yellow are set in stone, yes .i.e Green are odds and Yellow are evens.
    If first 5 entries are Cheque then 3,5,7,9 & 11 will be populated - correct, If the next is a Cash transaction, then i will prefer Row 4 to be populated as there could be multiple cash transactions as well.
    Valid reason: Formulas in each individual row that control Cash Float and Cheque Bank Balance which flows through to Trial Balance.

    My apologies...My file does not want to upload. Strange as it is only 186kb
    Last edited by sintek; 12-29-2015 at 07:10 AM.

  4. #4
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Vba code to populate next open alternate rows from userform

    I think you can change it to the following, I see the Cheque and Cash question as simply a need to determine the starting row of the scan for a blank row therefore Ive removed the additional setting of the cells.

    Please Login or Register  to view this content.
    You may want to move the resetting of values into the IF statement, depending on how you want it to handle there being no blank row in the 1st 49
    Last edited by pjwhitfield; 12-29-2015 at 07:14 AM.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,231

    Re: Vba code to populate next open alternate rows from userform

    Hi PJ

    Wow, an amazing improvement. There is however no differentiation with start row. i.e. Cheque or Cash starts in same row. and when i toggle between payments, it finds the last transaction and populates the nth row down.

  6. #6
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Vba code to populate next open alternate rows from userform

    I can only assume the words "Cheque" is not written exactly the same?

    try changing:

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    *note that Ive also changed the 1st letter of Cheque to lowercase* (an easy thing to miss but massive impact!)

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,231

    Re: Vba code to populate next open alternate rows from userform

    Hi PJ

    The words were written the same way, however, EUREKA, your new code change sorted it out.

    Thanks for your expertise and lesson.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,231

    Re: Vba code to populate next open alternate rows from userform

    Hi PJ

    The words were written the same way, however, EUREKA, your new code change sorted it out.

    Thanks for your expertise and lesson.

+ 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. Re-code Userform to open range of sheets like previous sheet code
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-15-2014, 02:31 AM
  2. Exit Userform to return to main code, but keep userform open
    By jombler74 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-04-2014, 04:01 AM
  3. [SOLVED] Populate Multiple rows from a Userform
    By Rigger32 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2014, 06:38 AM
  4. UserForm help - display list of open workbooks except workbook userform code is in
    By kensweep in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-09-2014, 12:26 PM
  5. one userform to populate different rows but same column
    By kmakjop in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-09-2013, 06:34 PM
  6. VBA code to populate userform
    By perrymagic in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-02-2011, 11:22 AM
  7. [SOLVED] Userform ComboBox populate using code?
    By Marc Cowlin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2006, 09:40 AM

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