Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Mike Echo
 
Posts: n/a
Default Finding a range from a column using VBA.

I have a table of info with set data in columns and dates down the first
column (A). What is the easiest way to get a range of dates (eg one
month)? Getting the related data via offset I understand, but I don't
know how to find the startrow and endrow to begin.

Any help appreciated, even a general pointer for me to research. I just
don't know where to start.

TIA.

R.
  #2   Report Post  
Arvi Laanemets
 
Posts: n/a
Default

Hi

=MATCH(DATE(2005,4,1),A:A,1)
returns the row number of cell with first April date in column A (i.e. when
the first cell in column A with April 2005 date contains April 2nd 2005,
then this row is returned. As follows, you must have column A sorted to work
properly). Or the position of first May, June, ... etc date, when there is
no date from April 2005.
=MATCH(DATE(2005,4,1),A:A,0)
returns the row number of first occurrence of April 1st 2005 in column A.
When there is not such a date, an error is returned.

You can both expressions use in OFFSET to calculate the second parameter
(the number of rows to offset from base cell)

--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets


"Mike Echo" wrote in message
...
I have a table of info with set data in columns and dates down the first
column (A). What is the easiest way to get a range of dates (eg one
month)? Getting the related data via offset I understand, but I don't
know how to find the startrow and endrow to begin.

Any help appreciated, even a general pointer for me to research. I just
don't know where to start.

TIA.

R.



  #3   Report Post  
Biff
 
Posts: n/a
Default

Hi!

Not sure how to implement this in VBA but a worksheet formula might start
you in the right direction.

Using Offset to find the start and end of the range:

I assume the dates are in consecutive order ascending and you want data for
the entire month.

=OFFSET(A1,MATCH(1,MONTH(A1:A100),0)-1,,EOMONTH(1,0))

I'm using the month of January in my example.

You use the Match function to find the start of the range. January has 31
days in it so you want a range 31 rows from the start of the range.

Eomonth (requires the Analysis ToolPak add-in) is the HEIGHT argument and
evaluates to 31.

Now, if I were entering this as a worksheet formula I would select a range
of cells 31 rows high and enter the formula as an array.

Biff

"Mike Echo" wrote in message
...
I have a table of info with set data in columns and dates down the first
column (A). What is the easiest way to get a range of dates (eg one
month)? Getting the related data via offset I understand, but I don't
know how to find the startrow and endrow to begin.

Any help appreciated, even a general pointer for me to research. I just
don't know where to start.

TIA.

R.



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
Finding last cell with data in a column Nigel Bennett Setting up and Configuration of Excel 2 April 29th 05 08:03 PM
up to 7 functions? ALex Excel Worksheet Functions 10 April 12th 05 06:42 PM
Dynamic Print Range Help waxwing Excel Worksheet Functions 2 February 21st 05 03:47 PM
Finding and Deleting duplicates in a column Brian Excel Worksheet Functions 3 February 5th 05 02:19 PM
how to enter a formula using column() function for a range Mike Peter Excel Worksheet Functions 6 December 8th 04 07:11 AM


All times are GMT +1. The time now is 08:09 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"