Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default VBA code for Date ranges

I have 12 cycles based on date range - Cycle 1: July 3 - Aug 3, Cycle 2: Aug
4 - Sep 7,..., Cycle 12: June 25 - June 29. The cycle does not have a fixed
no of days.

Help me how to program it such everytime I click a button, Excel will tag
the corresponding cycle.

Vlookup does not work since there are days not present in my cycles. I don't
want to list down all 365 days and assign cycle no because it defeats the
whole purpose of programming.

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default VBA code for Date ranges

Hi Rook,

Each date can be tested against the beginning and ending dates of your
12 cycles, an UDF can handle these 12 cases ...
Could you list all your cycles ?

Cheers
Carim

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default VBA code for Date ranges

Hi Carim,

Cycles as follows:

July 3 - Aug 3 Cyc 1
Aug 4 - Sep 4 Cyc 2
Sep 7 - OCt 4 Cyc 3
Oct 5 - Nov 6 Cyc 4
Nov 7 - Dec 7 Cyc 5
Dec 8 - Jan 16 Cyc 6
Jan 17 - Feb 15 Cyc 7
Feb 16 - Mar 19 Cyc 8
Mar 20 - Apr 20 Cyc 9
Apr 23 - MAy 23 Cyc 10
May 24 - Jun 25 Cyc 11
Jun 26 - Jun 29 Cyc 12

Thanks for your help.

Rook





"Carim" wrote:

Hi Rook,

Each date can be tested against the beginning and ending dates of your
12 cycles, an UDF can handle these 12 cases ...
Could you list all your cycles ?

Cheers
Carim


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default VBA code for Date ranges

Rook,

Thanks for the Cycles ...

It seems Vlookup Fuction can work as follows :

=VLOOKUP(A1,F1:H12,3)

provided, it is built with an initial cell which refers to A1

with your table, say in range F1:H12, cell F1 would equal

=DATE(YEAR($A$1),7,3)

and all other cells dependent ...i.e +31, +1, +31, etc ...

HTH
Cheers
Carim

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA code for Date ranges

VLOOKUP can work if you test for no match and action accordingly

=IF(ISNA(lookup_formula),"",lookup_formula)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Rook" wrote in message
...
I have 12 cycles based on date range - Cycle 1: July 3 - Aug 3, Cycle 2:

Aug
4 - Sep 7,..., Cycle 12: June 25 - June 29. The cycle does not have a

fixed
no of days.

Help me how to program it such everytime I click a button, Excel will tag
the corresponding cycle.

Vlookup does not work since there are days not present in my cycles. I

don't
want to list down all 365 days and assign cycle no because it defeats the
whole purpose of programming.

Thanks




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
VLOOKUP for Zip Code Ranges JerseyJR Excel Worksheet Functions 2 September 6th 05 06:37 PM
Refer to Worksheet Ranges in Code Andibevan[_2_] Excel Programming 8 March 30th 05 12:20 PM
Problem with code about ranges cdb Excel Programming 2 March 4th 05 10:41 AM
Macro - code for ranges urgent!!! rjc_29 Excel Programming 3 February 20th 04 11:44 AM
Defining ranges in VB code Rachael Moody Excel Programming 5 January 27th 04 02:21 PM


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