Get all references from other cells to a specific cell

%3CLINGO-SUB%20id%3D%22lingo-sub-1773956%22%20slang%3D%22en-US%22%3EGet%20all%20references%20from%20other%20cells%20to%20a%20specific%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1773956%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20everybody%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20am%20working%20on%20a%20makro%20to%20change%20column%20height%20for%20merged%20cells%20-%20This%20works%20good%20so%20far.%3C%2FP%3E%3CP%3EBut%20now%20i%20do%20have%20another%20cell%2C%20that%20has%20a%20reference%20for%20the%20same%20content%20(same%20file%2C%20but%20in%20another%20sheet)%20by%20formula%20(e.g.%20%22%3DB5%22)%2C%20that%20needs%20the%20same%20makro%20to%20be%20run%20over%20it%20to%20adjust%20the%20height.%3C%2FP%3E%3CP%3EAnd%20i%20do%20not%20only%20have%201%20of%20these%20%22source%22%20cells%20but%20lot%20of%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20current%20makro%20i%20am%20working%20with%3C%2FP%3E%3CP%3EPrivate%20Sub%20Workbook_SheetChange(ByVal%20Sh%20As%20Object%2C%20ByVal%20Target%20As%20Range)%3C%2FP%3E%3CP%3EBest%20case%20would%20be%20to%20to%20the%20work%20within%20the%20same%20Sub.%3C%2FP%3E%3CP%3EI%20was%20also%20thinking%20about%20something%20like%20a%20reference-table%20but%20i%20asssume%20the%20performance%20would%20be%20to%20laggy.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20my%20question%20is%3A%20Is%20there%20any%20way%2C%20maybe%20something%20like%20Target.Item(1).Reference(1..n)%20for%20such%20case%3F%3C%2FP%3E%3CP%3EAlso%20in%20my%20mind%20is%20now%2C%20how%20does%20Excel%20internal%20know%20if%20i%20do%20have%20many%20of%20such%20formula-referencing%20cells%20(%22%3DB5%22)%2C%20that%20it%20does%20not%20have%20to%20check%20every%20cell%20within%20the%20whole%20sheet%20(%E2%86%921048576Zx16384S)%20to%20be%20updated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance%20for%20information%20and%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1773956%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1774008%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20all%20references%20from%20other%20cells%20to%20a%20specific%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1774008%22%20slang%3D%22en-US%22%3EFor%20better%20understanding%20please%20share%20the%20entire%20VBA%20code%20and%20the%20cell%20references%20you%20want%20to%20change%20their%20height.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1779200%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20all%20references%20from%20other%20cells%20to%20a%20specific%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1779200%22%20slang%3D%22en-US%22%3EYou%20have%20mentioned%20that%20%22They%20are%20all%20forms%22.%20I%20guess%20that%20you%20are%20talking%20about%20the%20User%20Forms%20for%20data%20entry%20!!%3CBR%20%2F%3EIf%20yes%20then%20data%20entry%20through%20User%20Form%20needs%20VBA%20code%2C%2C%2C%20since%20you%20are%20already%20using%20then%20unless%20you%20will%20not%20share%20existing%20VBA%20macro%20code%20with%20me%2Fus%2C%2C%2C%20how%20could%20I%20and%20others%20suggest%20that%20where%20you%20want%20to%20improve%20it%20!!%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello everybody,

 

i am working on a makro to change column height for merged cells - This works good so far.

But now i do have another cell, that has a reference for the same content (same file, but in another sheet) by formula (e.g. "=B5"), that needs the same makro to be run over it to adjust the height.

And i do not only have 1 of these "source" cells but lot of it.

 

In my current makro i am working with

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

Best case would be to to the work within the same Sub.

I was also thinking about something like a reference-table but i asssume the performance would be to laggy.

 

Now my question is: Is there any way, maybe something like Target.Item(1).Reference(1..n) for such case?

Also in my mind is now, how does Excel internal know if i do have many of such formula-referencing cells ("=B5"), that it does not have to check every cell within the whole sheet (→1048576Zx16384S) to be updated.

 

Thank you in advance for information and help.

6 Replies
Highlighted
For better understanding please share the entire VBA code and the cell references you want to change their height.
Highlighted

Thank you for your replay.

I think the VBA code itself is not so relevant. In addition it is company internal use.

My post is more like a basic question, if possible, and if yes, how?

 

Anyway for better understanding a summary:

I do have within 1 excel-file 3 sheets with slightly different content. They are all forms. Now we want to make the input easier for the user so the user does not always have to copy,paste information.

Lets say

 

In Sheet 1:

The user can insert in B2 - D30 different text/information/values (e.g. his name, company, telephone, amount of pieces, costs, etc...). In between there are explanations written down, the user can not change.

 

In Sheet 2:

There are about 20 cells with reference, e.g.

B2=Sheet1!B2

D10=Sheet1!C5

C70=Sheet1!B16

...

 

In Sheet 3:

There are about 10 cells with references, e.g.

B3=Sheet1!B4

B9=Sheet1!D5

F1=Sheet1!C17

...

 

The mapping can be 1:1 or 1:n.

The main task is, that for each of the referenced values within Sheet 2+3 the makro should also be run to do the work after the user inserts/changes values within Sheet1.

 

(Please do not hang on this code. It is only an example and not the real code. But the concept is identical.) Within the general/comprehensive Workbook-Code:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Len(Target.Value) > 5 Then
       Target.WrapText = True
    End If
End Sub

 

Now i do not want to create a makro program to check for each individual cell everytime. I want a general code that tells me which cell in Sheet2+3 is referencing to 1 specific cell in Sheet1.



I hope the task is now clear. Please let me know what you do think about this.

You have mentioned that "They are all forms". I guess that you are talking about the User Forms for data entry !!
If yes then data entry through User Form needs VBA code,,, since you are already using then unless you will not share existing VBA macro code with me/us,,, how could I and others suggest that where you want to improve it !!

Highlighted

No Rajesh, i am sorry, but "Forms" was my description/translation for "excelsheet for the user", means no user-forms in VBA.

Highlighted

So, one last try: does any developer has an answer?

How does Sheet#1 know if some value in Sheet#2 has changed?

 

Thank you in advance.

Highlighted

@Christof_20  In VBA you a Range object has the following properties:

.Dependents

.Precedents

.DirectDependents

.DirectPrecedents

I think those properties should help you with your challenge.

I see your actual question is how sheet1 knows a value on sheet2 changed but you need to think it in reverse and say when value on sheet2 changes (OnChange event) then it checks its Dependents.

 

[[EDIT]] I just checked on these properties and they don't seem to be giving me the address(es) for corresponding cells on other sheets.  I'm not sure why and if I'm making a mistake but I see it giving the precedents and dependents from the same sheet but not a different sheet.  hopefully I'm just missing something.