+ Reply to Thread
Results 1 to 2 of 2

Getting data from a spreadsheet and displaying it on a userform

Hybrid View

  1. #1
    Registered User
    Join Date
    03-17-2012
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    1

    Getting data from a spreadsheet and displaying it on a userform

    hello there

    I am creating an excel vba program that will be used for recording chemical and fertiliser applications in agriculture. There are many areas of the program I need help with but firstly I would like to know how to get information from a table within a spreadsheet and show that data on a userform, then to be able to modify that data and save it back to the table on the spreadsheet.

    I have created a userform that allows the user to select the Farm and then a specific Field from a combobox. Then I would like the program to show the Field name and Size in two different textboxes, this data is in the spreadsheet in cels A3 and B3.

    This is the code I have so far for selecting the Farm and Field and displaying the Field Size.

    Private Sub ComboBox2_Change()
    TextBox1.Value = FieldSize(ComboBox2.Value)
    End Sub
    --------------------------------------------------------
    Private Sub ComboBox2_DropButt*******()
    Select Case ComboBox1.Value
    Case Range("A4")
    ComboBox2.RowSource = "'Admin Data'!B4:B6"
    Case Range("A5")
    ComboBox2.RowSource = "'Admin Data'!D4:D6"
    Case Range("A6")
    ComboBox2.RowSource = "'Admin Data'!F4:F6"
    End Select
    End Sub
    ----------------------------------------------------------------
    Public Function FieldSize(FieldName) As String
    With Worksheets("Admin Data").Range("B:F")
    Set C = .Find(FieldName, LookIn:=xlValues, lookat:=xlWhole)
    If Not C Is Nothing Then
    FieldSize = C.Offset(0, 1).Value
    Else
    FieldSize = "Not Found"
    End If
    End With
    End Function


    Many thanks in advance for your help

    Ben

  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: Getting data from a spreadsheet and displaying it on a userform

    Ben,

    Welcome to the forum.
    To undersand your request could you attach a copy of the workbook?
    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.

+ 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