Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Create non-contiguius range "IF"

Hi All.......
If someone would be so kind, I need help to create a non-contiguious range,
based on a similar principal to SUMIF........instead of summing the values
from the cells in column B adjacent to my selections in column A, I would
like to assemble all of the individual cells in column B into a
non-contiguious range and give it a RangeName. Sort of like....
=MAKERANGEIF(A:A,Choice,B:B)

Any guidance would be much appreciated..........

TIA
Vaya con Dios,
Chuck, CABGx3


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Create non-contiguius range "IF"

The general approach would be:

Sub MAKERANGEIF()
Dim rng as Range, rng1 as Range
Dim choice as Variant, cell as Range
Choice = "ABCD"
set rng = Range(Cells(1,1),Cells(rows.count,1).End(xlup))
for each cell in rng
if cell.Value = Choice then
if rng1 is nothing then
set rng1 = cell.offset(0,1)
else
set rng1 = Union(rng1, cell.offset(0,1))
end if
end if
Next
if not rng1 is nothing then
rng1.Name = "MyName"
end if
End Sub

If you really want a UDF, post back.

--
Regards,
Tom Ogilvy


"CLR" wrote in message
...
Hi All.......
If someone would be so kind, I need help to create a non-contiguious

range,
based on a similar principal to SUMIF........instead of summing the values
from the cells in column B adjacent to my selections in column A, I would
like to assemble all of the individual cells in column B into a
non-contiguious range and give it a RangeName. Sort of like....
=MAKERANGEIF(A:A,Choice,B:B)

Any guidance would be much appreciated..........

TIA
Vaya con Dios,
Chuck, CABGx3




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create non-contiguius range "IF"

Hi Chuck,

Here is an example of one way, not name driven, but it works

=SUMPRODUCT(SUMIF(INDIRECT({"B1","B4","B6","B8"}), "Choice",INDIRECT({"A1","A
4","A6","A8"})))

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CLR" wrote in message
...
Hi All.......
If someone would be so kind, I need help to create a non-contiguious

range,
based on a similar principal to SUMIF........instead of summing the values
from the cells in column B adjacent to my selections in column A, I would
like to assemble all of the individual cells in column B into a
non-contiguious range and give it a RangeName. Sort of like....
=MAKERANGEIF(A:A,Choice,B:B)

Any guidance would be much appreciated..........

TIA
Vaya con Dios,
Chuck, CABGx3




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Create non-contiguius range "IF"

Just for interest,
Sum works as well - doesn't require Sumproduct

--
Regards,
Tom Ogilvy


"Bob Phillips" wrote in message
...
Hi Chuck,

Here is an example of one way, not name driven, but it works


=SUMPRODUCT(SUMIF(INDIRECT({"B1","B4","B6","B8"}), "Choice",INDIRECT({"A1","A
4","A6","A8"})))

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CLR" wrote in message
...
Hi All.......
If someone would be so kind, I need help to create a non-contiguious

range,
based on a similar principal to SUMIF........instead of summing the

values
from the cells in column B adjacent to my selections in column A, I

would
like to assemble all of the individual cells in column B into a
non-contiguious range and give it a RangeName. Sort of like....
=MAKERANGEIF(A:A,Choice,B:B)

Any guidance would be much appreciated..........

TIA
Vaya con Dios,
Chuck, CABGx3






  #5   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Create non-contiguius range "IF"

As always.....your code is "Finer than frog hair"..........

Thanks Tom,

Vaya con Dios,
Chuck, CABGx3



"Tom Ogilvy" wrote:

The general approach would be:

Sub MAKERANGEIF()
Dim rng as Range, rng1 as Range
Dim choice as Variant, cell as Range
Choice = "ABCD"
set rng = Range(Cells(1,1),Cells(rows.count,1).End(xlup))
for each cell in rng
if cell.Value = Choice then
if rng1 is nothing then
set rng1 = cell.offset(0,1)
else
set rng1 = Union(rng1, cell.offset(0,1))
end if
end if
Next
if not rng1 is nothing then
rng1.Name = "MyName"
end if
End Sub

If you really want a UDF, post back.

--
Regards,
Tom Ogilvy


"CLR" wrote in message
...
Hi All.......
If someone would be so kind, I need help to create a non-contiguious

range,
based on a similar principal to SUMIF........instead of summing the values
from the cells in column B adjacent to my selections in column A, I would
like to assemble all of the individual cells in column B into a
non-contiguious range and give it a RangeName. Sort of like....
=MAKERANGEIF(A:A,Choice,B:B)

Any guidance would be much appreciated..........

TIA
Vaya con Dios,
Chuck, CABGx3







  #6   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Create non-contiguius range "IF"

Thanks Bob, that's very interesting, and I'll for sure put it in my secret
stash for someday, but for this immediate reqirement, Tom hit the nail right
on my head......

Vaya con Dios,
Chuck, CABGx3



"Bob Phillips" wrote:

Hi Chuck,

Here is an example of one way, not name driven, but it works

=SUMPRODUCT(SUMIF(INDIRECT({"B1","B4","B6","B8"}), "Choice",INDIRECT({"A1","A
4","A6","A8"})))

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CLR" wrote in message
...
Hi All.......
If someone would be so kind, I need help to create a non-contiguious

range,
based on a similar principal to SUMIF........instead of summing the values
from the cells in column B adjacent to my selections in column A, I would
like to assemble all of the individual cells in column B into a
non-contiguious range and give it a RangeName. Sort of like....
=MAKERANGEIF(A:A,Choice,B:B)

Any guidance would be much appreciated..........

TIA
Vaya con Dios,
Chuck, CABGx3





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
Create Pivot Table Data with Column "Sum" rather than "count" defa Johnny_99[_2_] Excel Discussion (Misc queries) 2 January 2nd 10 03:25 PM
How do I create a "SUMIF" based upon a Date Range? SRacak Excel Worksheet Functions 1 March 9th 09 07:44 PM
Create pivot table, error "Range is not valid" Daniel Charts and Charting in Excel 3 July 12th 07 11:12 PM
create links to check boxes marked "good" fair"and "bad" pjb Excel Worksheet Functions 3 April 20th 06 02:17 AM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM


All times are GMT +1. The time now is 06:28 PM.

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

About Us

"It's about Microsoft Excel"