Userform Help!!!!Please
Make it Public. Make it simpler and faster with:
Public Function FindLastRow()
'Find the last row in the database
FindLastRow = Cells(rows.count,1).End(xlup).row
End Function
--
Regards,
Tom Ogilvy
"Jennifer" wrote in message
...
Does this help?
Private Sub GetData()
Public LastRow As Long
'shows the getdata routine
Dim r As Long
If IsNumeric(RowNumber.Text) Then
r = CLng(RowNumber.Text)
Else
ClearData
MsgBox "Illegal row number"
Exit Sub
End If
If r 1 And r <= LastRow Then
txtInvoice.Text = Cells(r, 2)
txtDate.Text = Cells(r, 3)
cboVend.Text = Cells(r, 4)
cboRan.Text = Cells(r, 5)
txtPallet.Text = Cells(r, 7)
txtQty.Text = Cells(r, 8)
txtPrice.Text = Cells(r, 10)
txtFrt.Text = Cells(r, 11)
txtRepakHrs.Text = Cells(r, 13)
txtRepakQty.Text = Cells(r, 14)
DisableSave
ElseIf r = 1 Then
ClearData
Else
ClearData
MsgBox "invalid row number"
End If
End Sub
Private Sub ClearData()
txtInvoice.Text = ""
txtDate.Text = ""
cboVend.Text = "None"
cboRan.Text = "None"
txtPallet.Text = ""
txtQty.Text = ""
txtPrice.Text = ""
txtFrt.Text = ""
txtRepakHrs.Text = ""
txtRepakQty.Text = ""
End Sub
Private Sub DisableSave()
cmdSave.Enabled = False
btnClose.Enabled = False
End Sub
Private Sub UserForm_Initialize()
GetData
LastRow = FindLastRow
Dim cItem As Range
With Me.cboVend
For Each cItem In wksLookupLists.Range("VendorList")
.AddItem cItem.Value
.List(.ListCount - 1, 1) = cItem.Offset(0, 1).Value
Next
End With
With Me.cboRan
For Each cItem In wksLookupLists.Range("RanchIDList")
.AddItem cItem.Value
.List(.ListCount - 1, 1) = cItem.Offset(0, 1).Value
Next
End With
txtDate.Value = Date
End Sub
Private Function FindLastRow()
'Find the last row in the database
Dim r As Long
r = 2
Do While r < 65536 And Len(Cells(r, 1).Text) 0
r = r + 1
Loop
FindLastRow = r
End Function
"Bob Phillips" wrote:
Where is your FindLastRow function?
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Jennifer" wrote in message
...
Please Help, I am in dier need of some help.
I am using an example in a book and it says to add
<LastRow = FindLastRow to
the UserForm_Initialize event. As you can see I did, BUT I keep
getting a
"Variable not defined" rigth there. Help! Yes, I know it is probably
very
basic.
Thank you!
Private Sub UserForm_Initialize
GetData
LastRow = FindLastRow
Dim cItem As Range
With Me.cboVend
For Each cItem In wksLookupLists.Range("VendorList")
.AddItem cItem.Value
.List(.ListCount - 1, 1) = cItem.Offset(0, 1).Value
Next
End With
With Me.cboRan
For Each cItem In wksLookupLists.Range("RanchIDList")
.AddItem cItem.Value
.List(.ListCount - 1, 1) = cItem.Offset(0, 1).Value
Next
End With
txtDate.Value = Date
End Sub
--
Though daily learning, I LOVE EXCEL!
Jennifer
Expand AllCollapse All
--
Though daily learning, I LOVE EXCEL!
Jennifer
|