Following some advice i may of posted in the wrong place last time! This is a re-post.
Hello to all! My first post.
I have been looking over the internet for some hours now but I cannot find a solution to a problem I have.
I'm trying to validate an account number that a user inputs into a text box on a userform (VB6).
This is by cross referencing against a list of pre-defined account numbers on a separate sheet in the workbook.
My code so far looks like this (I keep getting mis match 13)
Private Sub submit_Click()
Worksheets("Audit_Data").Select
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Audit_Data")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a acct number
If Trim(Me.acctnumber.Value) = "" Then
Me.acctnumber.SetFocus
MsgBox "Please Enter Account Number"
Exit Sub
End If
' THIS IS THE CHALLENGE
If Range("A1:A1000").Value <> Me.acctnumber.Value Then
MsgBox "Please Enter Correct Account Number"
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.acctnumber.Value
ws.Cells(iRow, 2).Value = Me.action.Value
ws.Cells(iRow, 3).Value = Me.comments.Value
ws.Cells(iRow, 4).Value = Me.recheck.Value
'clear the data
Me.acctnumber.Value = ""
Me.action.Value = ""
Me.comments.Value = ""
Me.recheck.Value = ""
Me.acctnumber.SetFocus
Dim nResult As Long
nResult = MsgBox( _
Prompt:="Data Transfered, Do You Need To Enter Another Account?", _
Buttons:=vbYesNo)
If nResult = vbYes Then
Exit Sub
Else: Unload Me
End If
End Sub
Also i need to ref another work sheet?
Really hope you can help!
Mike.
Hello to all! My first post.
I have been looking over the internet for some hours now but I cannot find a solution to a problem I have.
I'm trying to validate an account number that a user inputs into a text box on a userform (VB6).
This is by cross referencing against a list of pre-defined account numbers on a separate sheet in the workbook.
My code so far looks like this (I keep getting mis match 13)
Private Sub submit_Click()
Worksheets("Audit_Data").Select
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Audit_Data")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a acct number
If Trim(Me.acctnumber.Value) = "" Then
Me.acctnumber.SetFocus
MsgBox "Please Enter Account Number"
Exit Sub
End If
' THIS IS THE CHALLENGE
If Range("A1:A1000").Value <> Me.acctnumber.Value Then
MsgBox "Please Enter Correct Account Number"
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.acctnumber.Value
ws.Cells(iRow, 2).Value = Me.action.Value
ws.Cells(iRow, 3).Value = Me.comments.Value
ws.Cells(iRow, 4).Value = Me.recheck.Value
'clear the data
Me.acctnumber.Value = ""
Me.action.Value = ""
Me.comments.Value = ""
Me.recheck.Value = ""
Me.acctnumber.SetFocus
Dim nResult As Long
nResult = MsgBox( _
Prompt:="Data Transfered, Do You Need To Enter Another Account?", _
Buttons:=vbYesNo)
If nResult = vbYes Then
Exit Sub
Else: Unload Me
End If
End Sub
Also i need to ref another work sheet?
Really hope you can help!
Mike.