Turn cell address found through a loop into a hyperlink

dellehurley

Board Regular
Joined
Sep 26, 2009
Messages
171
Office Version
  1. 365
Platform
  1. Windows
This code works fine except I would like to create a hyperlink or any other way of jumping directly to cell.
Column A (currently the cell address to be linked too)
or
Column B (associated File Name) if this was turned into A hyperlink I would delete column A
Any help would be appreciated.

VBA Code:
Sub Check_Recs()
'Check that the are Rec No matches the no. of files people connected.

Dim DbWs As Worksheet
Dim ErrWs As Worksheet
Dim DbLastRow As Long
Dim ErrLastRow As Long
Dim ErrEmptyRow As Long
Dim RecNo As Variant
Dim RecSub As Variant
Dim NumFileName As Integer
Dim FileName As String
Dim DbRange As Range
Dim DbARange As Range
Dim i As Long

Set DbWs = ThisWorkbook.Sheets("Database")
Set ErrWs = ThisWorkbook.Sheets("CheckForErrors")

DbLastRow = DbWs.Cells(Rows.Count, "A").End(xlUp).Row
ErrLastRow = ErrWs.Cells(Rows.Count, "A").End(xlUp).Row
ErrEmptyRow = ErrWs.Cells(Rows.Count, "A").End(xlUp).Row + 1

Set DbRange = ThisWorkbook.Sheets("Database").Range("A2", ThisWorkbook.Sheets("Database").Range("L" & Application.Rows.Count).End(xlUp))  'Dynamic Range "A:L
Set DbARange = ThisWorkbook.Sheets("Database").Range("A2", ThisWorkbook.Sheets("Database").Range("A" & Application.Rows.Count).End(xlUp))  'Dynamic Range "A" no header

For i = 2 To DbLastRow
    FileName = DbRange.Cells(i, 1).Value
    RecNo = DbRange.Cells(i, 11).Value
    RecSub = DbRange.Cells(i, 11).Value
    NumFileName = Application.WorksheetFunction.CountIf(ThisWorkbook.Sheets("Database").Range _
    ("A2", ThisWorkbook.Sheets("Database").Range("L" & Application.Rows.Count).End(xlUp)), DbARange.Cells(i, 1).Value)

        If NumFileName = RecNo Then
            If RecSub = "" Then
                ErrWs.Cells(ErrEmptyRow, 1).Value = DbRange.Cells(i, 1).Address
                ErrWs.Cells(ErrEmptyRow, 2).Value = DbRange.Cells(i, 1).Value
                ErrWs.Cells(ErrEmptyRow, 3).Value = DbRange.Cells(i, 6).Value
                ErrWs.Cells(ErrEmptyRow, 4).Value = DbRange.Cells(i, 7).Value
                ErrWs.Cells(ErrEmptyRow, 5).Value = DbRange.Cells(i, 11).Value
                ErrWs.Cells(ErrEmptyRow, 6).Value = DbRange.Cells(i, 12).Value
                ErrEmptyRow = ErrWs.Cells(Rows.Count, "A").End(xlUp).Row + 1
            End If
        Else
            ErrWs.Cells(ErrEmptyRow, 1).Value = DbRange.Cells(i, 1).Address
            ErrWs.Cells(ErrEmptyRow, 2).Value = DbRange.Cells(i, 1).Value
            ErrWs.Cells(ErrEmptyRow, 3).Value = DbRange.Cells(i, 6).Value
            ErrWs.Cells(ErrEmptyRow, 4).Value = DbRange.Cells(i, 7).Value
            ErrWs.Cells(ErrEmptyRow, 5).Value = DbRange.Cells(i, 11).Value
            ErrWs.Cells(ErrEmptyRow, 6).Value = DbRange.Cells(i, 12).Value
            ErrEmptyRow = ErrWs.Cells(Rows.Count, "A").End(xlUp).Row + 1
        End If
Next i
Call MessageBoxError2
End Sub

An example of what the result of the code looks like this...
Data_Entry_Form_ver_25 NEW EDIT.xlsm
ABCDEF
1Cell AddressFile NameRINFull Name and YOBRec NoRec Sub
2$F$1152FIn3642.jpg7g
3$F$2333FIn2845.jpgRoach, Cyril Anthony (b. 1920c)2b
4$F$2374PBu2822.jpgScott, Matilda3c
5$F$2486PBu2771.jpg6f
6$G$1152FIn3642.jpg7g
7$G$2486PBu2771.jpg6f
8$K$4944PIn0417.jpg231jpg
9$L$4740PMa0337.jpg157Smith, William Ian (b. 1922)5
10$L$4741PMa0337.jpg159Frith, John (b. 1870)5
CheckForErrors


Dannielle
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This code works fine except I would like to create a hyperlink or any other way of jumping directly to cell.
Column A (currently the cell address to be linked too)
or
Column B (associated File Name) if this was turned into A hyperlink I would delete column A
Any help would be appreciated.

VBA Code:
Sub Check_Recs()
'Check that the are Rec No matches the no. of files people connected.

Dim DbWs As Worksheet
Dim ErrWs As Worksheet
Dim DbLastRow As Long
Dim ErrLastRow As Long
Dim ErrEmptyRow As Long
Dim RecNo As Variant
Dim RecSub As Variant
Dim NumFileName As Integer
Dim FileName As String
Dim DbRange As Range
Dim DbARange As Range
Dim i As Long

Set DbWs = ThisWorkbook.Sheets("Database")
Set ErrWs = ThisWorkbook.Sheets("CheckForErrors")

DbLastRow = DbWs.Cells(Rows.Count, "A").End(xlUp).Row
ErrLastRow = ErrWs.Cells(Rows.Count, "A").End(xlUp).Row
ErrEmptyRow = ErrWs.Cells(Rows.Count, "A").End(xlUp).Row + 1

Set DbRange = ThisWorkbook.Sheets("Database").Range("A2", ThisWorkbook.Sheets("Database").Range("L" & Application.Rows.Count).End(xlUp))  'Dynamic Range "A:L
Set DbARange = ThisWorkbook.Sheets("Database").Range("A2", ThisWorkbook.Sheets("Database").Range("A" & Application.Rows.Count).End(xlUp))  'Dynamic Range "A" no header

For i = 2 To DbLastRow
    FileName = DbRange.Cells(i, 1).Value
    RecNo = DbRange.Cells(i, 11).Value
    RecSub = DbRange.Cells(i, 11).Value
    NumFileName = Application.WorksheetFunction.CountIf(ThisWorkbook.Sheets("Database").Range _
    ("A2", ThisWorkbook.Sheets("Database").Range("L" & Application.Rows.Count).End(xlUp)), DbARange.Cells(i, 1).Value)

        If NumFileName = RecNo Then
            If RecSub = "" Then
                ErrWs.Cells(ErrEmptyRow, 1).Value = DbRange.Cells(i, 1).Address
                ErrWs.Cells(ErrEmptyRow, 2).Value = DbRange.Cells(i, 1).Value
                ErrWs.Cells(ErrEmptyRow, 3).Value = DbRange.Cells(i, 6).Value
                ErrWs.Cells(ErrEmptyRow, 4).Value = DbRange.Cells(i, 7).Value
                ErrWs.Cells(ErrEmptyRow, 5).Value = DbRange.Cells(i, 11).Value
                ErrWs.Cells(ErrEmptyRow, 6).Value = DbRange.Cells(i, 12).Value
                ErrEmptyRow = ErrWs.Cells(Rows.Count, "A").End(xlUp).Row + 1
            End If
        Else
            ErrWs.Cells(ErrEmptyRow, 1).Value = DbRange.Cells(i, 1).Address
            ErrWs.Cells(ErrEmptyRow, 2).Value = DbRange.Cells(i, 1).Value
            ErrWs.Cells(ErrEmptyRow, 3).Value = DbRange.Cells(i, 6).Value
            ErrWs.Cells(ErrEmptyRow, 4).Value = DbRange.Cells(i, 7).Value
            ErrWs.Cells(ErrEmptyRow, 5).Value = DbRange.Cells(i, 11).Value
            ErrWs.Cells(ErrEmptyRow, 6).Value = DbRange.Cells(i, 12).Value
            ErrEmptyRow = ErrWs.Cells(Rows.Count, "A").End(xlUp).Row + 1
        End If
Next i
Call MessageBoxError2
End Sub

An example of what the result of the code looks like this...
Data_Entry_Form_ver_25 NEW EDIT.xlsm
ABCDEF
1Cell AddressFile NameRINFull Name and YOBRec NoRec Sub
2$F$1152FIn3642.jpg7g
3$F$2333FIn2845.jpgRoach, Cyril Anthony (b. 1920c)2b
4$F$2374PBu2822.jpgScott, Matilda3c
5$F$2486PBu2771.jpg6f
6$G$1152FIn3642.jpg7g
7$G$2486PBu2771.jpg6f
8$K$4944PIn0417.jpg231jpg
9$L$4740PMa0337.jpg157Smith, William Ian (b. 1922)5
10$L$4741PMa0337.jpg159Frith, John (b. 1870)5
CheckForErrors


Dannielle
I work out a simple work around. I'm putting the code just in case someone else is searching to do the same or similar
VBA Code:
Sub GotoDatabaseError()
'go to cell address in Database
FileAddress = ThisWorkbook.Worksheets("CheckForErrors").Range("A2").Value
Application.Goto (ActiveWorkbook.Sheets("Database").Range(FileAddress))
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,177
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