ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
My cell in column P is selected & a userform then pops up.
The invoice number shown will be entered in the active cell of which is in column P, as per photo attached.
The code on the button TRANSFER INV NUMBER TO DATABASE is as follows.
When the user runs the code not only will the inv number be added to my worksheet BUT i now also wish to add the todays date in column M
Would the code in Red below be correct ?
The invoice number shown will be entered in the active cell of which is in column P, as per photo attached.
The code on the button TRANSFER INV NUMBER TO DATABASE is as follows.
When the user runs the code not only will the inv number be added to my worksheet BUT i now also wish to add the todays date in column M
Would the code in Red below be correct ?
Code:
Private Sub TransferInvNumber_Click()
ActiveCell.Value = TransferInvoiceNumber.TextBox1.Value
ActiveCell.Offset(-3) = "Date"
.NumberFormat = "dd/mm/yyyy"
Unload Me
Const FILE_PATH As String = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\"
If ActiveCell.Column = Columns("P").Column Then
If Dir(FILE_PATH & ActiveCell.Value & ".pdf") <> "" Then
ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:=FILE_PATH & ActiveCell.Value & ".pdf"
Else
ActiveCell.Hyperlinks.Delete
MsgBox (FILE_PATH & ActiveCell.Value & ".pdf" & vbNewLine & vbNewLine & "FILE IS NOT IN FOLDER SPECIFIED, PLEASE CHECK PATH IS CORRECT"), vbCritical
End If
Else
MsgBox "PLEASE SELECT AN INVOICE NUMBER.", vbExclamation, "HYPERLINKING THE INVOICE NUMBER"
End If
End Sub