Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 210
Default dynamic range question

I have a formula (written by someone else) that takes a column and makes a
dynamic named range based on how many rows of data there are in a different
column. The code is:

ActiveWorkbook.Names.Add "TaxRegime", _

"=Central_Benefit!$IC$1:INDEX(Central_Benefit!$IC$ 1:$IC$999,COUNTA(Central_Benefit!$K$1:$K$999))"

My question is, how can I take this formula and make it dynamic for the
column as well? I want to do a search for the the column header
"tax_regime", then use that instead of saying column IC. (I hope that makes
sense).

Any help is very much appreciated. :-)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default dynamic range question

Dim iLastRow As Long
Dim iLastCol As Long
iLastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
iLastCol = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
ActiveWorkbook.Names.Add "TaxRegime", _
"=Central_Benefit!$IC$1:$" & _
Split(Columns(iLastCol).Address(, False), ":")(1) & _
"$" & iLastRow


--
HTH

Bob Phillips

"Robin" wrote in message
...
I have a formula (written by someone else) that takes a column and makes a
dynamic named range based on how many rows of data there are in a

different
column. The code is:

ActiveWorkbook.Names.Add "TaxRegime", _


"=Central_Benefit!$IC$1:INDEX(Central_Benefit!$IC$ 1:$IC$999,COUNTA(Central_B
enefit!$K$1:$K$999))"

My question is, how can I take this formula and make it dynamic for the
column as well? I want to do a search for the the column header
"tax_regime", then use that instead of saying column IC. (I hope that

makes
sense).

Any help is very much appreciated. :-)




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 210
Default dynamic range question

So far, so good, but we still have one instance of IC in there and I'm not
familiar enough with the split function to know how to put that in there
instead (just after central_benefit in the names.add). Can you help? Thanks
again and again!

"Bob Phillips" wrote:

Dim iLastRow As Long
Dim iLastCol As Long
iLastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
iLastCol = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
ActiveWorkbook.Names.Add "TaxRegime", _
"=Central_Benefit!$IC$1:$" & _
Split(Columns(iLastCol).Address(, False), ":")(1) & _
"$" & iLastRow


--
HTH

Bob Phillips

"Robin" wrote in message
...
I have a formula (written by someone else) that takes a column and makes a
dynamic named range based on how many rows of data there are in a

different
column. The code is:

ActiveWorkbook.Names.Add "TaxRegime", _


"=Central_Benefit!$IC$1:INDEX(Central_Benefit!$IC$ 1:$IC$999,COUNTA(Central_B
enefit!$K$1:$K$999))"

My question is, how can I take this formula and make it dynamic for the
column as well? I want to do a search for the the column header
"tax_regime", then use that instead of saying column IC. (I hope that

makes
sense).

Any help is very much appreciated. :-)





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 210
Default dynamic range question

I got it. Thanks again for your help. :-)

Dim iLastRow As Long
Dim iCol As Long
iLastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
iCol = Cells.Find(What:="tax_regime", _
After:=Range("A1"), _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
ActiveWorkbook.Names.Add "regime", _
"=Central_Benefit!$" & Split(Columns(iCol).Address(, False), ":")(1)
& "$1:$" & _
Split(Columns(iCol).Address(, False), ":")(1) & _
"$" & iLastRow

"Robin" wrote:

So far, so good, but we still have one instance of IC in there and I'm not
familiar enough with the split function to know how to put that in there
instead (just after central_benefit in the names.add). Can you help? Thanks
again and again!

"Bob Phillips" wrote:

Dim iLastRow As Long
Dim iLastCol As Long
iLastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
iLastCol = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
ActiveWorkbook.Names.Add "TaxRegime", _
"=Central_Benefit!$IC$1:$" & _
Split(Columns(iLastCol).Address(, False), ":")(1) & _
"$" & iLastRow


--
HTH

Bob Phillips

"Robin" wrote in message
...
I have a formula (written by someone else) that takes a column and makes a
dynamic named range based on how many rows of data there are in a

different
column. The code is:

ActiveWorkbook.Names.Add "TaxRegime", _


"=Central_Benefit!$IC$1:INDEX(Central_Benefit!$IC$ 1:$IC$999,COUNTA(Central_B
enefit!$K$1:$K$999))"

My question is, how can I take this formula and make it dynamic for the
column as well? I want to do a search for the the column header
"tax_regime", then use that instead of saying column IC. (I hope that

makes
sense).

Any help is very much appreciated. :-)





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default dynamic range question

LOL. I thought you wanted to start at IC regardless. Caused some oddities in
my test, because I ended before IC.

--
HTH

Bob Phillips

"Robin" wrote in message
...
I got it. Thanks again for your help. :-)

Dim iLastRow As Long
Dim iCol As Long
iLastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
iCol = Cells.Find(What:="tax_regime", _
After:=Range("A1"), _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
ActiveWorkbook.Names.Add "regime", _
"=Central_Benefit!$" & Split(Columns(iCol).Address(, False),

":")(1)
& "$1:$" & _
Split(Columns(iCol).Address(, False), ":")(1) & _
"$" & iLastRow

"Robin" wrote:

So far, so good, but we still have one instance of IC in there and I'm

not
familiar enough with the split function to know how to put that in there
instead (just after central_benefit in the names.add). Can you help?

Thanks
again and again!

"Bob Phillips" wrote:

Dim iLastRow As Long
Dim iLastCol As Long
iLastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
iLastCol = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
ActiveWorkbook.Names.Add "TaxRegime", _
"=Central_Benefit!$IC$1:$" & _
Split(Columns(iLastCol).Address(, False), ":")(1) & _
"$" & iLastRow


--
HTH

Bob Phillips

"Robin" wrote in message
...
I have a formula (written by someone else) that takes a column and

makes a
dynamic named range based on how many rows of data there are in a
different
column. The code is:

ActiveWorkbook.Names.Add "TaxRegime", _



"=Central_Benefit!$IC$1:INDEX(Central_Benefit!$IC$ 1:$IC$999,COUNTA(Central_B
enefit!$K$1:$K$999))"

My question is, how can I take this formula and make it dynamic for

the
column as well? I want to do a search for the the column header
"tax_regime", then use that instead of saying column IC. (I hope

that
makes
sense).

Any help is very much appreciated. :-)







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Odd Dynamic Range Question Bongard Excel Discussion (Misc queries) 6 January 7th 10 07:21 PM
Dynamic range question Guy Normandeau Excel Discussion (Misc queries) 13 August 2nd 06 07:31 AM
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM
Question regarding dynamic range setting dharmik Excel Worksheet Functions 2 July 22nd 05 08:44 PM
Dynamic Range Chart Macro Question GerbilGod7 Excel Programming 6 August 16th 04 12:04 PM


All times are GMT +1. The time now is 01:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"