Solved

Automatically hyperlinking to specific folder based on value entered in cell

Posted on 2014-03-22
5
367 Views
Last Modified: 2014-03-22
The following formula currently resides in Column G:
=IFERROR(HYPERLINK("Q:\20"&LEFT(F78,2)&"\"&IF(MID(F78,FIND("-",F78)+1,1)="9","DND\","")&TEXT(F78,"0000-00"),""&TEXT(F78,"0000-00")),"")

The formula references a numeric value in Column F, which corresponds to a folder name on the Q network drive. It takes the number in Column F, and creates a hyperlink to the correct network folder on Q based on the criteria within the formula (this criteria is outlined at the end of my question below), and autopopulates the hyperlinked folder number in Column G.

The numeric value in column F is always formatted as follows:
yy-xxxx where yy is the last 2 digits of a year, followed by a dash, followed by a 4-digit number.

Instead of having 2 columns with the same data, Column F with the un-hyperlinked folder number, and Column G with the hyperlinked folder number, I would like to:
1. Eliminate Column F
2. Have the user enter the folder number (yy-xxxx) into Column G, upon which the hyperlink would automatically be created, based on the same criteria as the current formula above (and outlined in detail below).

Outline of criteria contained in the current formula:

The 3 sub folders on the Q network drive that could contain the folder number entered by the user into Column G:
Q:\2013\DND
Q:\2014
Q:\2014\DND
All sub folders in the above folders are formatted the same way as described above: "yy-####".

If value entered into Column G is:
13-1###
13-2###
13-3###
13-4###
13-5###
13-6###
13-7###
13-8###
then the value needs to hyperlink to corresponding folder number within the 'Q:\2013' sub folder.

If value entered into Column G is:
13-9###
then the value needs to hyperlink to corresponding folder number within the 'Q:\2013\DND' sub folder:

If value entered into Column G is:
14-1###
14-2###
14-3###
14-4###
14-5###
14-6###
14-7###
14-8###
then the value needs to hyperlink to corresponding folder number within the 'Q:\2014' sub folder.

If value entered into Column G is:
14-9###
then the value needs to hyperlink to corresponding folder number within the 'Q:\2014\DND' sub folder:

Thanks,
Andrea
0
Comment
Question by:Andreamary
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 39947661
Hi,

pls try

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 Then ' Col G
    If Target.Value Like "##-####" Then
        If Target.Value Like "##-9###" Then
            addDND = "DND\"
        Else
            addDND = ""
        End If
        Application.EnableEvents = False
        Target.Formula = "=HYPERLINK(""Q:\20" & Left(Target, 2) & "\" & addDND & Target.Value & Chr(34) & ")"
        Application.EnableEvents = True
    End If
End If
End Sub

Open in new window

Regards
0
 

Author Comment

by:Andreamary
ID: 39947704
Thanks for the quick response!

It worked the first time I clicked on the cell in Column G, but when I went back and clicked on the same cell, it didn't work, and seemed to be adding "C:\20C:\" to the path every time I reclicked as shown below:

=HYPERLINK("C:\20C:\C:\20C:\C:\2013\13-5555")

Secondly, clicking on it changed the cell value from the original "13-5555" to "C:\2013\13-5555", and my hope is for the cell value to stay as 13-5555, as it did when using the formula (as there are some long filepaths and it clutters the spreadsheet). Is that possible?

Thanks!
Andrea
0
 

Author Comment

by:Andreamary
ID: 39947717
Sorry, my error! Just realized I caused the error above by mis-entering your solution — I hadn't included the third line of code. Now that I have, link works multiple times just fine.

So if it would be possible to resolve my second point above — having the cell value remain unchanged after it is clicked, showing just the folder number (i.e., 13-5555) as originally entered instead of changing to include the filepath, that would be great!

Thanks again,
Andrea
0
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39947738
pls try

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 Then ' Col G
    If Target.Value Like "##-####" Then
        If Target.Value Like "##-9###" Then
            addDND = "DND\"
        Else
            addDND = ""
        End If
        Application.EnableEvents = False
        Target.Formula = "=HYPERLINK(""Q:\20" & Left(Target, 2) & "\" & addDND & Target.Value _
            & Chr(34) & "," & Chr(34) & Target.Value & Chr(34) & ")"
        Application.EnableEvents = True
    End If
End If
End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:Andreamary
ID: 39947787
Perfect...thanks so much, Rgonzo!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Companies keep a much closer eye on costs today, so changing to new Technology – Microsoft Office 365 is the smartest move to take.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question