VBA Hyperlink using variable

gmain1978

New Member
Joined
Jun 23, 2021
Messages
5
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
Hi,
I need some help if possible. I have a workbook with some information in a table ("Sheet!") which gets added to information in a form in a second sheet ("Sheet3"), sheet3 then gets saved using a variable from cell I6 as an excel sheet. If possible I would like to add a hyperlink into the first sheet row (column AD) showing that the information was sent and the link to the saved excel sheet. Hopefully this makes sense.
 

Attachments

  • Issues.JPG
    Issues.JPG
    34.2 KB · Views: 20

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
This is the first part of the code to save the file, I then have another sub (SendNCR) to generate an email and attach this saved sheet.

VBA Code:
ub SaveNCR()
'
'
Dim Fname   As String
Dim FPath   As String
Dim NCR_No As String
NCR_No = Range("I6")
Fname = "NCR " & NCR_No & ".xlsx"
FPath = "\\Network_share\users\NEW QUALITY NCR SYSTEM\RETURNED NCR'S\"
'
    Range("A1:J66").Copy
    Workbooks.Add
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValidation, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    'Selection.PasteSpecial Paste:=xlPasteImage, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    ChDir "\\Network_share\users\NEW QUALITY NCR SYSTEM\RETURNED NCR'S"
    ActiveWorkbook.SaveAs Filename:= _
        FPath & Fname, FileFormat _
        :=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
    ActiveWindow.SmallScroll Down:=-76
    Call SendNCR
 
    
End Sub
 
Upvote 0
I managed to get it done with the following.
VBA Code:
 Dim ra As Range

    Set ra = Cells.Find(What:=NCR_No, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False)

    If ra Is Nothing Then
        MsgBox ("Not found")
        Else
        MsgBox (ra.Row)
    End If
    Range("AD" & ra.Row).Select
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="\\Network_share\users\New Quality NCR System\Returned NCR's\NCR " & NCR_No & ".xlsx", _
        TextToDisplay:="NCR SENT"
 
Upvote 0
Solution

Forum statistics

Threads
1,224,816
Messages
6,181,139
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top