+ Reply to Thread
Results 1 to 5 of 5

Excel VBA Loop with a Form

  1. #1
    Registered User
    Join Date
    07-18-2011
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Excel VBA Loop with a Form

    I have an Excel spreadsheet that has 4 columns - Year, Make, Model, and Price - all relating to vehicles. This spreadsheet will be used for a car auction and sometimes could have 20 rows - and sometimes could have 200 rows - all depending on the amount of vehicles for sale that week. I have created a form that when you click it - has text boxes mapped to each value in a row on the form for the columns I previously mentioned. I also have a spinner control that will increase (or decrease) the price textbox by 100 on each click. Everything so far works OK.

    I added a button to this form called "Next Vehicle" and when I click this button, I want it to go down a row via a loop I'm assuming (for example, row 2 to Row 3), and grab the new values for the 4 columns to display. When I click the "Next Vehicle" button again, then it should go down another row (for example, row 3 to row 4) and grab the new values for the 4 columns to display again. This should continue until it goes down a row and the field is blank - which means there are no more vehicles for sale.

    I have attached the Excel form that I feel I'm fairly close on as well as the contents of the button's code below. Any assistance is appreciated!

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Excel VBA Loop with a Form

    chad15,

    Welcome too the forum.

    In the attachment I modified the column for the "Stating Bid". I also modified the code for the "Next" button on the form.
    Attached Files Attached Files
    Charles

    There are other ways to do this, this is but 1 !
    Be Sure you thank those who helped.
    IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.

  3. #3
    Registered User
    Join Date
    07-18-2011
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Excel VBA Loop with a Form

    Thank you so much Charles! I see everything is working now as I would like it to! The one question I have is I lose the formatting when I use the spinner up/down button for the Bid Price. By formatting, I mean the "$" sign and the ",". I'm assuming this is because I am using "Me.txtStartingBid.Text" - however - I don't see an option for "Me.txtStartingBid.Number" or something similar. Can you advise what the syntax should be to correct this?

    Thanks again for the quick turn around help - looks like I found a great forum for future projects!

    Chad

  4. #4
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Excel VBA Loop with a Form

    chad15,

    Try.


    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-18-2011
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Excel VBA Loop with a Form

    Thanks, again, Charles. This resolved my issue. It's great to have a resource like you for assistance!

    Chad

+ 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