+ Reply to Thread
Results 1 to 5 of 5

Help with custom data entry form with dropdown lists populated by table columns...

  1. #1
    Registered User
    Join Date
    03-06-2014
    Location
    United Kingdom
    MS-Off Ver
    Mac - Office 2011
    Posts
    8

    Help with custom data entry form with dropdown lists populated by table columns...

    I am new to excel programming and would like some help with a custom data entry form...

    I have created a userform called userform1, I would like this userform to be permanently located on/within the Sheet 'User Input' so it can be modified without a pup-up window appearing (minor issue though).

    As you will see there are a couple of text input boxes and some drop down lists.
    For the first drop down list, I would like the list to be populated with the names of the fuels that are found in the column "Fuels" on table "tblFuels" on sheet "Fuel Data", I've been unable to find a solution online. Should I use a Vlookup function or something similar?

    Also I'm unaware how to enter the data from the text boxes in to specific cells, what function do i need and how do a reference a cell? Is it something like this: Worksheets(2).Range(B4)or Cells(B4)? I'm sure this is simple but i haven't found what I'm looking for.

    If you take a look at the code for the 'userform1' you will see I've added some description of what i would like the form to do upon data being entered or when the "Calculate" button is pressed. Basically when a user enters some data and specifies the units of the data from a dropdown list, I want the form/macro to convert the value in to the other possible units and put the values in to some cells on a sheet.
    This is my thoughts but I'm unsure on the commands/functions that i need.

    Private Sub txtOpPress_Change()

    'Put this value in to cells depending on the Unit's specified, i.e:
    'If ListBoxOpPressUnits = mmHg then
    'Put Value in to cell B5 on Worksheet(3)
    'enter the value in the function 'mmHg2mBar' as variable 'UserInput' and put the result in cell B6 in worksheet(3)
    'also enter the value in the function 'mmHg2kPa' as variable 'UserInput' and put the result in cell B7 in worksheet(3)
    'End If
    'If ListBoxOpPressUnits = mBar then
    'Put Value in to cell B6 on Worksheet(3)
    'enter the value in the function 'mBar2mmHg' as variable 'UserInput' and put the result in cell B5 in worksheet(3)
    'also enter the value in the function 'mBar2kPa' as variable 'UserInput' and put the result in cell B7 in worksheet(3)
    'End If
    'If ListboxOpPressUnits = kPa Then
    'Put Value in to cell B7 on Worksheet(3)
    'enter the value in the function 'kPa2mBar' as variable 'UserInput' and put the result in cell B6 in worksheet(3)
    'also enter the value in the function 'kPa2mmHg' again as variable 'UserInput' and put the result in cell B5 worksheet(3)
    'End If


    'Or would it be easier to put the value in to different cells depending on the Units? The final converted values would still need to be in the same cells as above.

    I will continue working on the rest of the spreadsheet in the mean time and I'm sure there will be more questions to come but any help will be much appreciated.

    File:
    Fuels Spreadsheet.xlsm
    Last edited by gaz1man; 03-13-2014 at 05:23 PM.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Help with custom data entry form with dropdown lists populated by table columns...

    This is not complete, but it should point you in the right direction.
    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    03-06-2014
    Location
    United Kingdom
    MS-Off Ver
    Mac - Office 2011
    Posts
    8

    Re: Help with custom data entry form with dropdown lists populated by table columns...

    Thats great thanks for that, I've decided to not use a userform and just use the cells on Worksheet(2) with a button I put in with the Developer tab. I've assigned a macro to the button and used the Select Case you provided and changed the values around a bit, but nothing happens when i click the button or run the macro..
    Sub Button2_Click()


    Select Case Worksheets(2).Range("B9")

    Case "mmHg"
    Worksheets(3).Range("b5") = Worksheets(2).Range("B7")
    Worksheets(3).Range("b7") = Module1.mmHg2kPa(Worksheets(2).Range("B7"))
    Worksheets(3).Range("b6") = Module1.mmHg2mBar(Worksheets(2).Range("B7"))
    Case "mBar"
    Worksheets(3).Range("b6") = Worksheets(2).Range("B7")
    Worksheets(3).Range("b5") = Module1.mBar2mmHg(Worksheets(2).Range("B7"))
    Worksheets(3).Range("b7") = Module1.mBar2kPa(Worksheets(2).Range("B7"))
    Case "kPa"
    Worksheets(3).Range("b7") = Worksheets(2).Range("B7")
    Worksheets(3).Range("b6") = Module1.kPa2mBar(Worksheets(2).Range("B7"))
    Worksheets(3).Range("b5") = Module1.kPa2mmHg(Worksheets(2).Range("B7"))

    End Select

    Worksheets(3).Range("b8") = Worksheets(3).Range("B5")

    End Sub

    Am i missing something?

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Help with custom data entry form with dropdown lists populated by table columns...

    Set a breakpoint (F9) and click the button; When the code stops, hover over Worksheets(2).Range("B9") and see if it's showing the right data. F8 to step through the code.

  5. #5
    Registered User
    Join Date
    03-06-2014
    Location
    United Kingdom
    MS-Off Ver
    Mac - Office 2011
    Posts
    8

    Re: Help with custom data entry form with dropdown lists populated by table columns...

    Thanks I've managed to fix it by entering the worksheet names as Worksheets("User Input") as it seems using Worksheets(2) refers to the order of the sheets along the bottom. i.e. it was looking for and entering data in the wrong places, and moving the sheets around messed up everything!

    I have another problem but I'll start a new thread.
    Thanks again for the help!

+ 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. Data Entry Form and drop down lists
    By AnneFr in forum Excel General
    Replies: 1
    Last Post: 10-29-2012, 08:35 AM
  2. Calendar on Custom Data entry form - how to?
    By JohnRooney in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-12-2010, 01:32 PM
  3. Custom Data Entry Form
    By JohnRooney in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-13-2009, 09:27 AM
  4. Create a Custom Data Entry Form
    By Nolesphan30 in forum Excel General
    Replies: 11
    Last Post: 02-05-2008, 06:27 PM
  5. how do I add data validation dropdown lists to a Form
    By SteveD.IFlora in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-21-2005, 01:06 PM

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