Is it possible to extract cell reference from a hyperlink? - excel

I've been researching this one for a while now with no luck, so thought I would open it up here...
Let's say you have two worksheets in an excel workbook, e.g. sheet1 and sheet2.
Now, in sheet2 cell A1, say you have a hyperlink that refers/points/links to sheet1 cell A1. In other words, the value of the cell reference of the hyperlink at sheet2!A1 is sheet1!A1
Do you know if there is a formula or function that would return the cell reference of that hyperlink.
i.e.
=<formula-or-function>(sheet2!A1)
which returns 'sheet1!A1' as its result.

You can retrieve the .SubAddress from the Hyperlinks.Item Property.
'by the active cell
With ActiveCell
Debug.Print .Hyperlinks.Item(1).SubAddress
End With
'by worksheet and cell address
With Worksheets("Sheet2").Range("D6")
Debug.Print .Hyperlinks.Item(1).SubAddress
End With
This is, of course, VBA. I know of no way to perform this action with a worksheet formula short of a User Defined Function (aka UDF) written in VBA.

Related

what mean range.hyperlink(1).address = range.value

what mean
range.hyperlink(1).address = range.value
First of all it is Hyperlinks (plural) then Range.Hyperlinks… needs to specify a range address like Range("A1").Hyperlinks…. Same for Range.Value.
So either
Range("A1").Hyperlinks(1).Address = Range("A1").Value
or
Dim Rng As Range
Set Rng = Range("A1")
Rng.Hyperlinks(1).Address = Rng.Value
So now what does it do?
It takes the first hyperlink that exists in the specified range eg Range("A1") and changes the URL of that hyperlink to the Value in that cell A1.
Be careful when you copy hyperlink cells
But be careful if you create a hyperlink eg in A1 and copy the whole cell into a range (more than one cell) A2:A10 the new inserted links will refer to the exact same hyperlink object, because the hyperlink object is only duplicated once (per inserted range) but not once (per inserted cell)! So in A2:A10 all cells now reference the same hyperlink object.
You can check that by using Cells.Hyperlinks.Count it will show 2 as result even if you see 10 hyperlinks in cells A1:A10.
That means if you then run
Range("A2").Hyperlinks(1).Address = Range("A2").Value
not only the URL of the hyperlink in A2 changes but the URL of the hyperlinks in A3:A10 are changed to the value of cell A2 too, because it is the exact same hyperlink object (they share).
To get distinct hyperlink objects in each cells A2:A10 you need to copy A1 and insert one by one each cell eg. paste in A2 then A3 then A4 …
This way for every pasted cell a unique hyperlink object is created.

excel copy/paste cell to cell using address in another cell

How to Copy/Paste a value from 1 cell to 2nd Cell using a 3rd Cell which holds the address of the 2nd Cell. I want to trigger the copy/past action by a 4th Cell going 'true'. I do not want to use VB as I am not competent with it.
You will need to use VBA I think. The only way to get a cell to show a value other than by programming is to enter a formula into your 2nd cell - but by definition you don't know what that is. Assume that A1 holds the value to copy, A3 is the cell holding the cell address and A4 is the true/false cell. Then you need this code in the module page of the sheet you wish to affect:
Private Sub Worksheet_Calculate()
If range("a4") then
range(range("a3").text).value = range("a1").value
End If
End Sub
Note this will error if A3 doesn't hold a valid cell address

IF statement to reference cell on another worksheet

I have an excel spreadsheet with numerous worksheets. I have a cell in Worksheet 1 that is a drop down list.
This cell is then populated on worksheet 2 C7 using a cell reference (i.e. ='Worksheet 1'!J30)
I want another cell on worksheet 2 that says if C7="Other" to then get the cell reference from 'Worksheet 1'!K30
Is this possible? Or is there a better way. It is a drop down list of suppliers.
Are you writing IF statement in VBA?

Can an Excel cell formula refer to a UserForm control?

I have a UserForm with text boxes that are already bound to certain worksheet cells through the ControlSource property. I need to run a calculation between two of these bound values and have the result end up in a third worksheet cell. I know there are numerous ways this can be done, but I'm wondering whether there's some way to do this as a formula in the worksheet cell that references the UserForm control values. For example, I would like to be able to put a formula in cell C3 that goes something like
= UserForm1.TextBox1.Value * UserForm1.TextBox2.Value
but I haven't found any reference that addresses using worksheet cell formulas to fetch values directly from UserForm controls. (And no, in this case I can't just reference the bound cells by plugging something like "= A1 * B2" into cell C3. This question is specifically about whether it's feasible to reference a UserForm control from within a worksheet cell formula.)
Thanks in advance for any helpful suggestions.
The only way to refer to the property of an ActiveX control on a worksheet, is via a user-defined-function, such as:
Public Function GetTextBoxValue(TextBoxName As String) As String
On Error GoTo 0
Dim o As OLEObject
Set o = Sheet1.OLEObjects(TextBoxName)
On Error Resume Next
If Not o Is Nothing Then
GetTextBoxValue = o.Object.Text
End If
End Function
Then call the function from a cell, like: =GetTextBoxValue("TextBox1")

How do I reference a cell in range of worksheets and look for a specific value in Excel?

Is this possible?
=IF(COUNTIF('**ALLSHEETS**'!D4, "ICT"),**SHEETNAME**, FALSE)
Excel will look up a a specific value ("ICT") in the same cell in every sheet then if that cell contains the value it will return the name of the sheet(s)
You can do it with a little trick
Put this Formula in Cell A1 of Everysheet you want to get searched
=IF(D4="ICT",MID(#CELL("filename",A1),FIND("]",#CELL("filename",A1))+1,255),"")
Then, in the required sheet!cell add all sheets like
=Sheet1!A1&Sheet2!A1&Sheet3!A1
Note: If it would be only one sheet having ICT and you are trying to find the sheet name, then this would be the easiest solution
But in case of multiple sheets having ICT in D4, the result would be a like
sheet1sheet2sheet3 in the same cell.

Resources