Possibility to use hyperlinks in a shared excel workbook - excel

I've got an excel document where we've enabled the "Track Changes" functionality in order to capture whose changes what and when - for this you'd have to share the workbook.
We've now found that we want to make it a bit easier to navigate in the file (as it's getting quite big) - and in this process we'd like to make use of hyperlinks between tabs.
Now I've looked around a bit to find out how to do this - because as you may know Excel doesn't allow you to use hyperlinks when the workbook is shared (at least not that I know of) - and I don't want to - unshare workbook > insert hyperlink > reshare - as that means losing the tracking we've made so far :(
I've been able to find an answer stating:
In the Formula Bar for the cell you want the link in, use the following formula:
=HYPERLINK("url_goes_here", "cell_content_here")
Now I've tried inserting something like this:
=HYPERLINK("'CHANGE LOG'!"; "CHANGE LOG") and alternatively
=HYPERLINK("'CHANGE LOG'"; "CHANGE LOG")
It does truly insert a hyperlink but I just get an error message stating "cannot open the specified file."
Is anyone aware of a workaround or able to tell if I'm doing something completely wrong?
Br, Thomas

Several other sites suggests to unshare, add links and then reshare the workbook but this is somewhat annoying because it prevents users that currently have it open from properly saving if you unshare while they have it open even if you reshare before they save.
No need to unshare then reshare just set the cell's Formula property to equal to =HYPERLINK(link, text)
Sheets(targetSheet).Range(targetRange).Formula = _
"=HYPERLINK(" & Chr(34) & "http://www.google.ca/" & Chr(34) & ", " _
& Chr(34) & "Click to go to google" & Chr(34) & ")"
Chr(34) are double quotes
The result formula is =HYPERLINK("http://www.google.ca/", "Click to go to google")
This is the workaround in VBA to allow hyperlinks in shared workbooks.
Sorry that this probably doesn't completely answer OP's question but this was the only SO topic regarding this problem so I thought I'd share in case anyone else stumbles here.

Try with this http://office.microsoft.com/en-001/excel-help/hyperlink-function-HP010342583.aspx
Section: Jump to a specific cell on a worksheet

Related

Use Excel to open a search window in Window Explorer

I have seen some topics on the subject, but I haven't been able to find exactly what I need. And because I am not familiar with VBA I have not been able to tweak the code to get it to work.
Here's what I am looking to accomplish:
I would like to have a macro (or excel formula) that when I click on the hyperlink it will open a Windows File Explorer in search mode.
In cell A1 is my path name (C:/users/images)
In cell A2 is the file name (Butterfly)
In cell A3 is the hyperlink that when I click on it it will open windows file explorer searching in the path C:/users/images for any files containing butterfly
Here is what I have found so far
Sub SearchFolder()
Call Shell("explorer.exe " & Chr(34) & "search-ms:query=butterfly&crumb=location:C:\users\images" & Chr(34), vbNormalFocus)
End Sub
This bit of code works, but it is hard coded. I need to made it dynamic so that the marco can pick up the the path and file name from the excel cells.
Any help is great! And like I said I am not familiar with VBA (it took me 3 days to find that code) so if you can provide the code as will that would be great!

Writing a formula from VBA not working on every end-user's PC

I hope someone will be able to help me sort this one out because I've been crawling the Internet for some time now and could not find any obvious reason why the behavior of my macro under Excel works for some users (including me of course) and does not work on some other users' laptops.
My objective:
Write from a VBA SubRoutine a vlookup formula in one cell. Based on that vlookup, either it finds something and it displays a text A or the vlookup throws an error and it then displays a text B.
The situation
Here is the formula if we were writing it directly in the sheet from the end-user's perspective: =IF(NOT(ISERROR(VLOOKUP(C2,DataSet2!$A$2:$A$12,1,0))),"Direct Report","Team member of direct report")
When we copy/paste that formula on a PC where the macro fails directly in the spreadsheet. It works.
When we run the macro actually trying to incorporate that formula in that exact same cell, it fails and throws an error 400.
Here is now the VBA code attempting to write the above formula in the cell:
formulaString = "=IF(NOT(ISERROR(VLOOKUP(C" & CStr(counter + 2) & systemListSeparator & "DataSet2!$A$2:$A$" & CStr(2 + totalDirectReportsCount) & systemListSeparator & "1" & systemListSeparator & "0)))" & systemListSeparator & """Direct Report""" & systemListSeparator & """Team member of direct report"")"
Selection.Offset(counter, 0).Formula = formulaString
So the above 2 statements, as you'll have understood probably, are included in a loop and for every single row I have, I want to add that formula in the first cell from the currently selected cell.
What drives me crazy is that: it works fine on my PC, it works fine on my colleague's PC who is in Finland, but on another colleague's PC also in Finland, it does not. I have Windows 10 and Office 2016, she has Windows 10 and office 2016 as well...
So I am really wondering if there could be some regional settings or Excel settings or System Settings which could make HER Excel not interpret my "formulaString" as viable for her laptop. I have made sure to fetch the list separator to avoid those usual regional settings easy traps but would there be other similar traps I am not aware of?
Thanks a lot for any hints I could follow to progress on my investigations.
Kind regards,
Nicolas C.
This is really a tricky point, but fortunately VBA provides an excellent solution.
Simply write the formula in Excel, select the cell and run the following code:
Public Sub TestMe()
With ActiveCell
Debug.Print .Formula
Debug.Print .FormulaLocal
Debug.Print .FormulaR1C1
End With
End Sub
In German Excel, this is what you would get:
=SUM(C1+D1)
=SUMME(C1+D1)
=SUM(RC[2]+RC[3])
Then rebuild your formulas, using only .Formula or .FormulaR1C1 and the result from the immediate window. Thus your colleagues from all over the world would be really happy. As noted in the 3 examples, the first and the third one always give the same answer, following the en_US format.
Another option is that Excel and VBA do not like your formula, because of the decimal separator in Finland, being different from the decimal separator in the USA. See How to add hardcoded float number values to the formula using VBA to change it a bit.
Solution
Nicolas C. edit: All the above comments and hereby answer have helped me solving my issue. Thank you very much guys for your prompt reaction and feedback. You really saved my day. So the root cause was indeed that I had tried to capture the end-user's system preferences on his/her locale and regional settings and making use of his/her list separator (which was ; actually) within the VBA script which was a bad move since, as mentioned by #AxelRichter and #Vityata, within a VBA script, .Formula needs always to be written in the en_US format, that is english function names, commas, etc.
I have now removed my user related list separator and replaced it with traditional commas and it solved my issue.

ExecuteExcel4Macro & update values dialog box

I'm currently coding a small VBA tool in order to quickly sort files according to some data inside. As an example, I have a "To be sorted" folder with some files in it, lets say "File1.xls, File2.xls" and so on.
To read data in "FileX.xls", I use ExecuteExcel4Macro (with the range and filename set properly), then I can use this data to apply filters and move files in other directories.
My code works fine with local files, but when I try to run it on my server (the tool aims at sorting files stored on the server), a dialog box "Update values" appears when I use ExecuteExcel4Macro.
From here, I have to options:
manually opening each file before running the macro (I have like 250 files to sort so...)
pressing cancel on the dialog box which causes the plugin to crash (type mismatch error)
Here is the portion of code that bothers me
For Each fsoFile In fsoParentFol.Files
'I only want to sort .xls files
If Right(fsoFile.Name, 4) = ".xls" Then
'On active le workbook actuel
strRef = "'[" & fsoFile.Name & "]" & "Sheet1" & "'!"
'this is the data I want to retrieve ... and this is where the dialog pops up
projectName = ExecuteExcel4Macro(strRef & rngProjectName.Address(1, 1, xlR1C1))
'some more code goes here but is irrelevant
End If
Next fsoFile
So my question is: how can I disable this dialog or, if it's a bad idea, are there other clean methods (I don't want to open each workbook, even with screenupdate turned off) that could solve my issue?
DisplayAlerts = False doesn't solve the problem. And again, the program runs fine without this dialog.
I've of course tried to research online my problem first before posting here, but even subjects like this one aren't solutions to my problem.
Change the UNC path to a path using the drive letter that the server is mapped to:
So for example, change your string to produce:
[P:\Some_Folder\myfile.xls]Sheet1!A1
Instead of:
[\\my-server\Some_Folder\myfile.xls]Sheet1!A1
You could try using the replace function to achieve this:
strRef = "'[" & Replace(fsoFile.Name, "\\", "P:\") & "]" & "Sheet1" & "'!"
I would use code more like this:
projectName = Workbooks.Open("\\srv1\folder\Book1.xlsx").Sheets("Sheet1").Range("a1")
Workbooks("Book1.xlsx").Close
This works with a mapped network drive too.

How to create hyperlinks with VBA to the same open workbook

The setup
I have an Excel workbook stored on my hard drive.
The structure is such that on the first sheet I have a list of the names of the other sheets in the same workbook (...which can be created or deleted).
All the names on the list, on the first sheet, are supposed to be hyperlinks to the corresponding sheet in the workbook. So, by clicking the name on the first sheet you jump to the corresponding sheet.
When a new sheet is created a macro creates also the new name on the list on the first sheet and makes a hypelink of it. This works.
...BUT...
The links point to the stored version of the file, not to the open workbook! Clicking the links opens the stored file and not the one which is under work.
QUESTION: How to create a hyperlink that always points to the same open workbook and not to the stored copy of it?
Try this:
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"Sheet3!", TextToDisplay:="Link to sheet #3"
Address is the URL and SubAddress is a localtion of the page (or a sheet or a range in excel workbooks).
You may try creating the hyperlink as a formula (via VBA, as you need).
I am using the parameters you posted, this may need a little adjustment.
Dim rngsrc as Range, rngtrgs as String
Set rngsrc = Worksheets("Summary").Cells(Cell.Row, 5)
Set rngtrg = "'" & sSheetName & "'!B5"
rngsrc.FormulaR1C1 = "=HYPERLINK(" & rngtrgs & "," & sSheetName & ")"
See
Official documentation
Example 1
Example 2
This (hopefully) answers your question. As a separate note, it still remains to be clarified why you see the behavior you see.
It seems that the problem comes from the following fact: My file is in a SharePoint folder. If I open it just for reading, the hyperlinks work fine. If I open the file for editing, a copy of the SharePoint file is placed on my hard disk, on a specified location. So, the path to the file is not the same as it would be if I open it read-only. Should I use hyperlink.follow to solve this?
So, this all comes down to the question: In VBA/Excel, can I create a hyperlink which always points to a location in the same opened file so that the hyperlink ignores the storage path of the corresponding file? Using empty string (or BLANK) doesn't help as the address parameter in hypelinks.add as Excel seems to automatically fill in the whole storage path.
I upgraded to Office 2013 and "PADAM": The problem vanished! It seems that there was a bug in Excel/VBA in this in the 2007 version.

Deleting hidden name definitions with invalid names in Excel 2003

I am using this macro:
http://support.microsoft.com/kb/119826
to try and clean up hidden names in my excel file. It works for most of the hidden names, but not for a few _123Graph names. I'm not sure where these names came from, but when I try to delete them I get a 1004 automation error.
The knowledge base mentions that names with spaces may cause an error. Is there a way to delete these?
Excel 2007 and above resolves this issue... but a quick fix for Excel 2003 is:
Go to the Tools Menu
- Options
- General tab
- Check R1C1 Reference Style
Then hit "Ok".
You will then be prompted for a new name for each of the corrupted names.
...then you can go back and uncheck the R1C1 check box.
I use the excellent Name Manager add-in to, erm, manage the named ranges in my workbooks, including all those pesky ones like the example you give that are automatically created by Excel when autofiltering etc. which aren't normally exposed.
It allows filtering of names by type, location, scope etc. and generally knocks the awful built-in dialog into next week.
Edit: If installing an add-in is out of the question then adding the following code in a standard module will allow you to loop through the names in the workbook and delete the offending items.
Sub deleteNamedRanges()
Dim n As Name
Dim a As Variant
For Each n In ThisWorkbook.Names
a = MsgBox("Do you want to delete the following name?:" & vbCrLf & vbCrLf & n.Name & " (" & n.RefersTo & ")", vbYesNo, "Delete ranges")
If a = vbYes Then
n.Delete
End If
Next n
End Sub
If there are a great many names then you should be able to modify this to suit your needs.

Resources