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
Bookmarks