VBA - Defined Name Range

stapuff

Well-known Member
Joined
Feb 19, 2004
Messages
1,126
I have an automation macro that does a lot of updating, cutting, pasting, etc and I have run into a situation that I don't seem to understand why it is happening.

Defined name ranges loose the range.

On sheet CH E3 I have the following formula

=SUMIF(CH_MyRange4,"<>",CH_MyRange3)+SUMIF(CH_MyRange2,"<>",CH_MyRange1)

The following is the formulas I have for each named range

CH_MYRange1 =OFFSET(Champs!$K$13,0,0,COUNTA(Champs!$K:$K),1)
CH_MYRange2 =OFFSET(Champs!$L$13,0,0,COUNTA(Champs!$L:$L),1)
CH_MYRange3 =OFFSET(Champs!$N$13,0,0,COUNTA(Champs!$N:$N),1)
CH_MYRange4 =OFFSET(Champs!$O$13,0,0,COUNTA(Champs!$O:$O),1)

When I click in the formula bar for each of the above the row column is never correct.

CH_MYRange1 =K13:K289
CH_MYRange2 =L13:L36
CH_MYRange3 =N13:N299
CH_MYRange4 =O13:O23

The last row is 281 and each range should be:

CH_MYRange1 =K13:K281
CH_MYRange2 =L13:L281
CH_MYRange3 =N13:N281
CH_MYRange4 =O13:O281


The end result is the sumif formula above fails to show correct results and just shows #REF error.

My thoughts were to re-define the named ranges within my macro.

Your thoughts.....


stapuff
 
Reguardless - I appreciate you putting me in the right direction. I never thought to use something like you suggested so I learned a couple things with solving this issue.

Again -

I appreciate all your help.

stapuff
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,585
Messages
6,179,703
Members
452,938
Latest member
babeneker

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