PhantomOak
New Member
- Joined
- Apr 20, 2011
- Messages
- 31
I have a userform that I want to input an invoice number, a vendor; I want to look for values in column A, and column B, and if they match, write to an adjacent cell (but first ask for conformation)
Right now it looks up the Invoice number in any cell in Table2 and writes offset to that value (no good).
Also, it only looks up the invoice number, and not the invoice and vendor (no good).
I have this so far
Help
Right now it looks up the Invoice number in any cell in Table2 and writes offset to that value (no good).
Also, it only looks up the invoice number, and not the invoice and vendor (no good).
I have this so far
Code:
Private Sub CommandButton4_Click()
Dim test1 As String
Dim FoundRange As Range
test1 = PaidInvoice.Value
Worksheets("Invoices").Activate
Set FoundRange = Sheets("Invoices").Cells.Find(what:=test1, LookIn:=xlFormulas, lookat:=xlWhole)
If FoundRange Is Nothing Then
MsgBox "No Invoice Found - (Invoice Number must match a previously recorded invoice)", vbExclamation, "Invoice Log"
Me.PaidInvoice.SetFocus
Else
Dim Answer As String
Dim MyNote As String
'Place your text here
MyNote = "Invoice '" & PaidInvoice.Value & " " & FoundRange.Offset(0, 1).Value & "'" & " will be marked 'PAID' : Continue?"
'Display MessageBox
Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "Correct Invoice?")
If Answer = vbNo Then
Me.PaidInvoice.SetFocus
Else
PaidInvoice.Text = FoundRange.Value
FoundRange.Offset(0, 7).Value = "Yes"
FoundRange.Offset(0, 8).Value = Format(Now, "mm/dd/yy")
End If
End If
End Sub
Help