Macro to create dynamic range

Worijaa

New Member
Joined
Jan 29, 2010
Messages
1
Hi <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
I have several cells that a need to name with reference to an offset formula to create a dynamic range. Instead of manually punching the names, I have created a macro. But it is not functioning properly. <o:p></o:p>
<o:p></o:p>
What I have done so far:<o:p></o:p>
<o:p></o:p>
I my excel sheet, column A contains the offset formula that the cell name should refer to and column D contains the name of that range. When I am using following code, I got the wrong reference in the formula<o:p></o:p>
The desire result is dynamic named range e.g. Date1 with reference to =OFFSET(Charts!J19;0;0;1;Charts!$M$3)<o:p></o:p>
<o:p> </o:p>
Appreciate if anyone could help<o:p></o:p>
-----<o:p></o:p>
<o:p> </o:p>
Sub AddName()<o:p></o:p>
Dim RngIndx As String<o:p></o:p>
Dim Strname As String<o:p></o:p>
Do Until ActiveCell.Row = 500<o:p></o:p>
If Selection.Interior.ColorIndex = 36 Then<o:p></o:p>
Strname = ActiveCell.Offset(, 3)<o:p></o:p>
ActiveWorkbook.Names.Add (Strname), RefersTo:=ActiveCell.Formula<o:p></o:p>
End If<o:p></o:p>
<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:eek:ffice:smarttags" /><st1:place w:st="on">Loop</st1:place><o:p></o:p>
End Sub<o:p></o:p>
<o:p></o:p>
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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