That error is a "Type mismatch" error... I cannot think of any way the code you are showing us could produce that error. Are you sure your code is stopping in the code you showed us and not in one in the Initialize or Activate events for the UserForm?
Thanks Rick.
It was definitely identifying the error at the point "DrugUserForm.Show.
I looked at the Initialize code and discovered that it just used UserForm as the name; so I changed this to "DrugUserForm" and the error didn't occur; however, all I get now is a blank form.
What should happen is that when the CommandButton is pressed, the details of whatever product is highlighted should show in the userform.
The first part of the form's code is as follows:
Private Sub DrugUserForm_Initialize()
Call GetTextBoxData
End Sub
Private Sub GetTextBoxData()
Dim v As String
Dim r As Integer
Dim DTBP As Currency
Dim DTWP As Currency
Dim diff As Variant
r = ActiveCell.Row
If Sheet6.Cells(r, "G").Value > 0 Then
dt = Sheet6.Cells(r, "G").Value
Else
dt = 0
End If
If Sheet6.Cells(r, "A").Value > "" Then
tbPSLCode.Text = Sheet6.Cells(r, "A").Value
End If
If Sheet6.Cells(r, "B").Value > "" Then
tbPipCode.Text = Sheet6.Cells(r, "B").Value
End If
I'm quite new to this so wonder if I'm missing something that's stopping the form from pulling in the data from sheet6.