Dynamic range with formula-based end

Patrunjel

New Member
Joined
Feb 10, 2012
Messages
9
Hi,
I would really appreciate if you could help me with something that I think it is not hard for someone that knows vba well. I don't. :confused:
I am trying to select a range whose end is variable. The end of the range is dependent on a formula that tries to find unique values. The fomula is =SUMPRODUCT(1/countif(rng, rng)I am a newbie to VBA and I don't know how to insert the end of the range to display the result of the SUMPRODUCT formula.

My code is:

Code:
<!-- BEGIN TEMPLATE: bbcode_code -->
 
Sub dstc()     
Sheets("Sheet1").SelectSheets("Sheet1").Range("H4:H" & Sheets("Sheet1").Range("H1").Value).Select
Selection.FormulaArray = "=distinctvalues(rng_A,TRUE)" 
End Sub

So far I've tricked it by pointing to a cell (H1) that displays the result of the sumproduct, but somebody may delete it someday. My dream is to have something such as:

Code:
<!-- BEGIN TEMPLATE: bbcode_code -->
Sheets("Sheet1").Range("H4:H" & [B]formula[/B] ).Value).Select

Thank you in advance for any help on this!
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top