I have been using the following hyperlink function to provide a link to a file based on the value of cell B3 — the function is located in cell L3 (and in Bn and Ln, as required).
=HYPERLINK(env("AGScan")&"\photos\"&B3&".jpg","photos\"&B3&".jpg")
As you can see this function uses the value of an Environment Variable called AGSCAN to provide the location of the file — in this case it would be C:\Data\Catalog — now using an environment variable is a bit restrictive — I would like to use the Hyperlink Base option instead since this is much easier to change and specify the file location in the hyperlink base in the Excel worksheet properties.
I can't seem to work out how to modify the above Hyperlink function to do this. Can anyone help me?
Thanks Brett, While I was waiting and hoping for someone to respond I did some more experimenting and came up with this solution
=HYPERLINK(B2&".jpg","photos\"&B2&".jpg")
which differs slightly from yours. I decided to put the full path in the hyperlink base field, so I think I need to have the cell reference followed by the concatenation symbol and then the literal text. I guess a slightly better version of mine would be
=HYPERLINK(B2&".jpg",B2&".jpg")
Are your and my expressions equivalent?
Once you have set the hyperlink base in the worksheet properties, just use the relative path to get your photos to display. The hyperlink base path will automatically be prepended.
If you set your base path to "C:\Data\Catalog", use something like the following:
=HYPERLINK("photos\B3.jpg", "photos\B3.jpg")
If you set your base path to "C:\Data\Catalog\photos", use something like the following:
=HYPERLINK("B3.jpg", "B3.jpg")
Related
I have an .xltm template spreadsheet that I'm wondering if I can get a macro to populate the "save as" file name based on cell data, is this possible?
There are over 7 people who will have this spreadsheet, it's more of a form, and we are trying to figure out a way to keep the filenames uniform. I know there is the ThisWorkbook.BeforeSave, but I'm not really having any luck there. I just need it to make a file named something like $A$1 R $B$1 T $B$3.xlsx
how ever the problem im having is that one of the celss will have a function "Today()" and sometimes it will be a regular text the picture I included is off code that doeas work but only if the cell have a regular text in them but not a function, I quess it is due to it being a string or variable or something.
enter image description here
Any ideas on how to do this? anything helps thank very much.
I see from the image that you are working with Mac OS. The thing that comes to mind immediately is that the forward-slash character (/) is not allowed in a file name in Mac OS and by default, TODAY() is going to include the forward-slash character. Try using the replace function to switch it out for an underscore (_). So if your cell B7 uses the TODAY() function replace it with:
replace(range("B7").value,"/","_")
It also seems a bit strange to save an .xltm template as .xls file. Be sure you understand the workbook.saveas method including the fileformat argument
I think that part of your code should be:
ActiveWorkbook.saveAs strPath, xlExcel8
We have formula in xls file as below
='SharePoint_FilePath/[ExcelFileName.xls]SheetName'!$B$4
For e.g.
='http://SharePointServer/Sites/SiteName/Shared Documents/[ExcelFileName.xls]SheetName'!$B$4
Once we download this file containing above formula, then it automatically appends local path to formula i.e. New formula will be:
='Download_Path\http:\SharePointServer\Sites\SiteName\Shared Documents\[ExcelFileName.xls]SheetName'!$B$4
I have tried to search on google, found some hints like as below:
Use UNC path for referring to another xls, instead of web url
path.
Uncheck "Update links on Save" in excel options.
But those are also not working.
Can anyone suggest any recommended way?
Thanks
In my user environment, we asked them to use Map Folder to SharePoint Portal and use consistent drive letter for the mapping.
Despite this, it is not good to do referring like that. It should be all in one Excel file. Links like this is easily broken (e.g. change of file name or moving to another folder) and very hard to maintain.
Should avoid doing that.
I am attempting to do something which sounds very simple, yet I couldn't find an answer anywhere online or here.
I am building an Excel database and have the main sheet with all the data I need, in which everything works great. I have many cells with text, and that text contains a hyperlink (in which I mean the URL is different than the text in the cell).
I have many other sheets which reference the main one. I have attempted to simply link the cells to their counterparts in the main (using a simple =location formula), but that only copies the text.
I then tried using =HYPERLINK(location), but that copies the text and creates a hyperlink, using the text as a URL instead of importing the URL I originally used.
What I want to do is link to another cell, displaying the text, but giving it the original URL I used in the main sheet.
EDIT: I want to be clear, that I can't use =HYPERLINK(location, name) because that still references the text in the original cell, NOT its hyperlink.
It could work if there would be a way to link a cell to the hyperlink in another cell, not the text in that cell.
Is such a thing possible at all without starting to use MACRO commands?
Not that it's a deal breaker, but I'd rather not get into it if I don't have to (since other people will work on it in the future, and they might not know anything about it).
A short User Defined Function (aka UDF) can strip the .Address property from the Hyperlink object.
Function what_url(rHL As Range)
If CBool(rHL.Cells(1).Hyperlinks.Count) Then
what_url = rHL.Hyperlinks(1).Address
Else
what_url = "not a hylerlink"
End If
End Function
There is also a .SubAddress property that can be appended to the .Address if required.
I am having a problem with a piece of code that I’m writing. I have created a “parent” workbook which will be used by multiple users as the basis for some basic reporting. This workbook creates a number of child workbooks by VBA. The end users then enter values in these child workbooks, which are aggregated in the parent workbook.
However, I am having trouble with using a variable in a formula. If I use a formula such as (eg)
ActiveCell.Formula = “=S:\ThisIs\AnExample\FilePath\Name.xlsx”
then the formula works fine. However, what I need to do is change the path so that “Name” in the example above is actually a variable (fname, which is a global [string] variable).
I thought something like
ActiveCell.Formula = “=S:\ThisIs\AnExample\FilePath\”& fname&”.xlsx”
(with a few brackets in relevant places) would do the trick, as that’s what seems to recommended in the responses I’ve seen to similar questions – but I’ve tried all sorts of permutations of bracketing of the above, none of which will do what I want.
To be on the safe side you could declare "Dim fname As String" and double-check the fname to make sure it is stripped from extension and generally trimmed correctly.
I'd say using a hardcoded path instead of a mapped path would be more reliable, if that is an option. It would prevent issues that would occur if a logon script failed to map the same drive letter to the specific network path the resource is stored in.
I need to convert the following formula to one that uses SUM(IF), as I am given a #value error when the external data source is closed.
=COUNTIFS(test1.xlsx!$B:$B,"Group1",
test1.xlsx!$C:$C,$D13,
test1.xlsx!$AB:$AB,">="&F12,
test1.xlsx!$AB:$AB,"<"&DATE(YEAR(F12),
MONTH(F12)+1,1))
Thanks in advance.
I don't see why you think SUM(IF) would make the situation any better. You need a worksheet name in your external links. So where I may have:
='E:\Temp\Stack Overflow\[Book1.xlsx]Sheet1'!$I$9
You are missing the reference to Sheet1 (or whatever worksheet you want to link to). Also, if 'Test1.xlsx' is not in the same folder as the current spreadsheet, you will need to include the path to the file (as in my example).