ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,731
- Office Version
- 2007
- Platform
- Windows
Hi,
Currently using this working code below.
It works fine BUT it currently checks a specific cell.
My goal is to look on sheet DATABASE in column A for the value that was taken from sheet INV cell G13 and then cell the cell on this row in column P
Example
Sheet INV G13 value is TOM JONES 001
Activate sheet DATABASE
Look in column A for TOM JONES 001
Now on this row check in column P if value is present.
Thanks.
Currently using this working code below.
It works fine BUT it currently checks a specific cell.
My goal is to look on sheet DATABASE in column A for the value that was taken from sheet INV cell G13 and then cell the cell on this row in column P
Example
Sheet INV G13 value is TOM JONES 001
Activate sheet DATABASE
Look in column A for TOM JONES 001
Now on this row check in column P if value is present.
Thanks.
Sub HYPERLINKP5()
Dim answer As Integer
Dim srcWS As Worksheet, destWS As Worksheet
Set srcWS = ActiveWorkbook.Worksheets("INV")
Set destWS = ActiveWorkbook.Worksheets("DATABASE")
If Trim(destWS.Range("P5").Value) <> "" Then
MsgBox "There is something in P5"
Exit Sub
Else
srcWS.Range("L4").Copy destWS.Range("P5")
With destWS
.Range("P5").Font.Size = 14
.Activate
.Range("P5").Select
Const FILE_PATH As String = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES TEST\"
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 With
End If
With Sheets("INV")
Worksheets("INV").Activate
Worksheets("INV").Range("G13").Select
With ActiveSheet
MsgBox "print disabled"
' ActiveWindow.SelectedSheets.PrintOut copies:=1
answer = MsgBox("DID THE INVOICE PRINT OK ?", vbInformation + vbYesNo, "INVOICE PRINT OK MESSAGE")
If answer = vbNo Then
Exit Sub
Else
Range("L4").Value = Range("L4").Value + 1
Range("G27:L36").ClearContents
Range("G46:G50").ClearContents
Range("L18").ClearContents
Range("G13").ClearContents
Range("G13").Select
ActiveWorkbook.Save
End If
End With
End With
End Sub