Hello,
Say I have a formula in A1 as
In Excel VBA, how can I extract those ranges? Which isPlease Login or Register to view this content.
A2:C100,B8,C10,A1-:B10,C1,C2,C3,C4,E10,E20,E30
In the above case?
Hello,
Say I have a formula in A1 as
In Excel VBA, how can I extract those ranges? Which isPlease Login or Register to view this content.
A2:C100,B8,C10,A1-:B10,C1,C2,C3,C4,E10,E20,E30
In the above case?
Hi dluhut- This macro uses the DirectPrecedents method to extract the addresses of any cells the ActiveCell depends on.
In this example, it just shows them in a msgbox.
NOTE: This approach has limitations. DirectPrecedents only finds cells on the ActiveSheet. Ranges on other Sheets are missed.Please Login or Register to view this content.
Also, if a formula uses G1 and G2 separately, DirectPrecedents shows them as one range G1:G2.
Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
Last edited by leelnich; 05-26-2017 at 02:45 PM.
Thanks leelnich!
But when I change Range("A1") to Range("AQ398") for example, it didn't give me any result.
FYI, Range("AQ398").Formula = SUMIFS($Z398:$AP398,$Z$5:$AP$5, AQ$5)
I just updated the code (02:45 pm) to act on the currently selected cell ("ActiveCell"). Try that, and read the notes at the bottom. It's NOT perfect!
Try this Userdefined Function.
Use Formula "=ExtractRanges(A1)" where A1 is A string or a cell address
Please Login or Register to view this content.
My General Rules if you want my help. Not aimed at any person in particular:
1. Please Make Requests not demands, none of us get paid here.
2. Check back on your post regularly. I will not return to a post after 4 days.
If it is not important to you then it definitely is not important to me.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks