J
Jennifer
The following runs like a champ until i try to increase the ranges. In the
sub how do I increase the data input. I also think I have to add something to
the source range. But i'm just not sure how. Thanks guys!
You will notice i have added in sub 1stData ***txtProdID.Text =
..List(.ListIndex, 2)***I guess what i am asking is when i click update how do
i get it to add that as well, if changes have been made. Oooodles and oodles
of thanks.
Option Explicit
Private source As Range
Private index As Long
Private market As String
****************************
Private Sub btnUpdate_Click()
Dim pointer As String
If txtDataID = "" Then Exit Sub
If Trim(txtBoxes.Text) = "" Then Exit Sub
If Not IsNumeric(txtBoxes.Text) Then Exit Sub
pointer = lstData.ListIndex
For index = 2 To source.Rows.Count
If source.Cells(index, 1) = txtDataID.Text Then
source.Cells(index, 4) = Trim(txtBoxes.Text)
Exit For
End If
Next
LoadData
lstData.ListIndex = pointer
End Sub
***************************
Private Sub lstData_Click()
With lstData
txtDataID.Text = .List(.ListIndex, 0)
txtProdID.Text = .List(.ListIndex, 2)
txtBoxes.Text = .List(.ListIndex, 3)
End With
End Sub
*****************************
Private Sub UserForm_Initialize()
With Worksheets("Database")
Set source = .Range(.Range("A1"), .Range("D1").End(xlDown))
End With
LoadMarkets
End Sub
*********************************
Private Sub LoadMarkets()
Dim markets As New Scripting.Dictionary
For index = 2 To source.Rows.Count
market = source.Cells(index, "k").Value
If Not markets.Exists(market) Then
markets.Add market, market
cmbMarket.AddItem market
End If
Next
End Sub
sub how do I increase the data input. I also think I have to add something to
the source range. But i'm just not sure how. Thanks guys!
You will notice i have added in sub 1stData ***txtProdID.Text =
..List(.ListIndex, 2)***I guess what i am asking is when i click update how do
i get it to add that as well, if changes have been made. Oooodles and oodles
of thanks.
Option Explicit
Private source As Range
Private index As Long
Private market As String
****************************
Private Sub btnUpdate_Click()
Dim pointer As String
If txtDataID = "" Then Exit Sub
If Trim(txtBoxes.Text) = "" Then Exit Sub
If Not IsNumeric(txtBoxes.Text) Then Exit Sub
pointer = lstData.ListIndex
For index = 2 To source.Rows.Count
If source.Cells(index, 1) = txtDataID.Text Then
source.Cells(index, 4) = Trim(txtBoxes.Text)
Exit For
End If
Next
LoadData
lstData.ListIndex = pointer
End Sub
***************************
Private Sub lstData_Click()
With lstData
txtDataID.Text = .List(.ListIndex, 0)
txtProdID.Text = .List(.ListIndex, 2)
txtBoxes.Text = .List(.ListIndex, 3)
End With
End Sub
*****************************
Private Sub UserForm_Initialize()
With Worksheets("Database")
Set source = .Range(.Range("A1"), .Range("D1").End(xlDown))
End With
LoadMarkets
End Sub
*********************************
Private Sub LoadMarkets()
Dim markets As New Scripting.Dictionary
For index = 2 To source.Rows.Count
market = source.Cells(index, "k").Value
If Not markets.Exists(market) Then
markets.Add market, market
cmbMarket.AddItem market
End If
Next
End Sub