+ Reply to Thread
Results 1 to 3 of 3

User Form to enter mileage

  1. #1
    Registered User
    Join Date
    09-26-2008
    Location
    North Myrtle Beach
    MS-Off Ver
    365 Business
    Posts
    82

    User Form to enter mileage

    Been a while since I have gotten to write some code, so I am a bit rusty. I have created a user form for the user to enter their mileage to go into an expense sheet. I have data validation in "B10:B25" along with VLookup in "C10:C25". My challenge is that I want the user form to pop up for the user to enter their mileage ONLY IF Mileage is celected in Column B, and then I want their input to be entered into the same row into the cell in column D. Note, there could be multiple "Mileage" entries in column B. I would prefer not to have a "Close Form" button, but would like the data to be inserted AND the form close upon the click of the "Enter" button on the user form.

    Any help would be appreciated

    Pleased ignore the rest of the sheet, as it is a complete WIP as I play with how we want to have it set up.
    Attached Files Attached Files
    Last edited by bjohnsonac; 12-19-2017 at 02:05 PM. Reason: Solved

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,843

    Re: User Form to enter mileage

    Attached is an example using the Change event on the worksheet. You can remove the Close button and associated code. I would have just used an InputBox for this instead of creating a new UserForm but I made changes to accommodate your design.

    This is part of your original code. It does not find the first empty cell in a row, it finds the first empty cell in the entire sheet. This will always be A1 on your sheet. Not sure what you are even trying to do there, it doesn't seem necessary.
    Please Login or Register  to view this content.
    I also added validation to ensure that what the user enters is a number.

    The strategy is for the userform to capture the mileage and make it available in a public variable. After the form is done the calling procedure retrieves the value from the public variable and writes it to the sheet.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-26-2008
    Location
    North Myrtle Beach
    MS-Off Ver
    365 Business
    Posts
    82

    Thumbs up Re: User Form to enter mileage

    Perfect! Thank you

+ 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. User form will not enter data on next empty row
    By RDMiller1955 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2017, 02:02 PM
  2. User Form to enter and get data in Excel
    By kjpeissner in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-18-2016, 07:10 PM
  3. [SOLVED] User Form with Empty row but user may enter data manually
    By Nole68 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2015, 11:35 AM
  4. User Form To enter Time
    By dollar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2009, 03:19 AM
  5. How To Enter A Value To A Cell With A User Form??
    By twofootgiant in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2008, 11:20 AM
  6. User Form to Enter Information
    By Wskip49 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2008, 02:30 PM
  7. Need to disable Enter key in User Form
    By iturnrocks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2007, 12:14 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