Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting a Range inside a range
Hi,
I can not do this because I want to select the range for build a chart per year. That´s why I must keep in a VB "range", all data for the same year. Best regards Hernan escribió en el mensaje ... Why not just use the built in function of count if and place it into a hidden (or not)colum of your choice. something like =COUNTIF($B$1:$B$371,Totals!C$5) Here I was looking at colum b from row 1 to row 371 to see if any matched the date that I had in c5 on my Totals page. But you can just as easly left it at =COUNTIF (A1:A500,mm/dd/yy) -----Original Message----- Hi what do you want to do with this selection afterwards? But one way could be (assumption: column A is sorted ascending) sub foo() dim rng as range dim row_start as long dim row_end as long dim row_index as long dim lastrow as long with activesheet lastrow = .Cells(Rows.count, "A").End(xlUp).row For row_index = 1 to lastrow if Year(.cells(row_index,1))=2004 then row_start=row_index exit for end if next For row_index = lastrow to row_start step -1 if Year(.cells(row_index,1))=2004 then row_end=row_index exit for end if next set rng=.range("B" & row_start & ":B" & row_end) end with rng.select end sub -- Regards Frank Kabel Frankfurt, Germany hcova wrote: Hi everybody: I have the following problem in VBA: a) I have the column A filled with dates formated as "mm/dd/yy". b) In the column B, for every date I have a associated a certain integer number. I want to select a range in column B that contains only the integers for a given year. NOTE: For simplicity I have sorted the column A by date. How can I do this? Regards . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I insert a dynamic reference of a range inside VLOOKUP? | Excel Worksheet Functions | |||
how can i use countif function inside a filtered range | New Users to Excel | |||
Selecting range in list of range names depending on a cell informa | Excel Discussion (Misc queries) | |||
Using a range variable inside a excel function | Excel Discussion (Misc queries) | |||
Check if a range is inside another | Excel Programming |