Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default PING ... Bob Philips

Many thanks for your help in previous thread,

Now I would like to replace some of the criteria with variables but I am
stumped with the dates ... e.g. in the code below I would like to replace
"2005-06-01" with StartDate a variable which holds the value of the first
day of the current month

StartDate = Format(DateAdd("d", -Day(Now() - 1), Now()), "yyyy-mm-dd")

However many permutations of Cdate, Cstr, Format etc I cannot get it to work
correctly would you mind showing me how it can be done

............ original code ............

evaluate("SUMPRODUCT(--(A2:A100=--""2005-06-01""),--(A2:A100<=--""2005-06-30""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")


Thanks again


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default PING ... Bob Philips

=Date - Day(Date) + 1


--
HTH
Roger
Shaftesbury (UK)
(A few miles further north than Bob P, and a few billion less brain cells)



"Jimbo" wrote in message
...
Many thanks for your help in previous thread,

Now I would like to replace some of the criteria with variables but I am
stumped with the dates ... e.g. in the code below I would like to replace
"2005-06-01" with StartDate a variable which holds the value of the first
day of the current month

StartDate = Format(DateAdd("d", -Day(Now() - 1), Now()), "yyyy-mm-dd")

However many permutations of Cdate, Cstr, Format etc I cannot get it to
work correctly would you mind showing me how it can be done

........... original code ............

evaluate("SUMPRODUCT(--(A2:A100=--""2005-06-01""),--(A2:A100<=--""2005-06-30""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")


Thanks again




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default PING ... Bob Philips

Roger,
I'm not sure what you are suggesting ... Did you intend that your code was
to be used to establish the value of the variable StartDate or as a direct
substitute in the line of vbaCode.

In either case I would be grateful if you would reproduce the code and also
the equivalent for a variable EndDate (the end of current month)

My apologies if I am appearring negative or 'thick' its because I'm becoming
more confused by the hour

Regards



"Roger Whitehead" wrote in message
...
=Date - Day(Date) + 1


--
HTH
Roger
Shaftesbury (UK)
(A few miles further north than Bob P, and a few billion less brain cells)



"Jimbo" wrote in message
...
Many thanks for your help in previous thread,

Now I would like to replace some of the criteria with variables but I am
stumped with the dates ... e.g. in the code below I would like to replace
"2005-06-01" with StartDate a variable which holds the value of the first
day of the current month

StartDate = Format(DateAdd("d", -Day(Now() - 1), Now()), "yyyy-mm-dd")

However many permutations of Cdate, Cstr, Format etc I cannot get it to
work correctly would you mind showing me how it can be done

........... original code ............

evaluate("SUMPRODUCT(--(A2:A100=--""2005-06-01""),--(A2:A100<=--""2005-06-30""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")


Thanks again






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default PING ... Bob Philips

Jimbo,

The correct way to do that is:

MsgBox Evaluate("SUMPRODUCT(--(A2:A100=--" & startdate &
"),--(A2:A100<=--""2005-06-30""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")

HTH,
Bernie
MS Excel MVP


"Jimbo" wrote in message
...
Many thanks for your help in previous thread,

Now I would like to replace some of the criteria with variables but I am
stumped with the dates ... e.g. in the code below I would like to replace
"2005-06-01" with StartDate a variable which holds the value of the first
day of the current month

StartDate = Format(DateAdd("d", -Day(Now() - 1), Now()), "yyyy-mm-dd")

However many permutations of Cdate, Cstr, Format etc I cannot get it to

work
correctly would you mind showing me how it can be done

........... original code ............


evaluate("SUMPRODUCT(--(A2:A100=--""2005-06-01""),--(A2:A100<=--""2005-06-3
0""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")


Thanks again




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default PING ... Bob Philips

Jimbo,

I think he was suggesting a way to calculate the first day of the month. Not
very useful, since you are already doing that.

HTH,
Bernie
MS Excel MVP


"Jimbo" wrote in message
...
Roger,
I'm not sure what you are suggesting ... Did you intend that your code was
to be used to establish the value of the variable StartDate or as a direct
substitute in the line of vbaCode.

In either case I would be grateful if you would reproduce the code and

also
the equivalent for a variable EndDate (the end of current month)

My apologies if I am appearring negative or 'thick' its because I'm

becoming
more confused by the hour

Regards





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default PING ... Bob Philips

Jimbo,

Of course, you don't need the "Msgbox" part, and the line wrapping occurred
at a bad place.

Basically, replace

--(A2:A100=--""2005-06-01"")

with

--(A2:A100=--" & startdate & ")

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Jimbo,

The correct way to do that is:

MsgBox Evaluate("SUMPRODUCT(--(A2:A100=--" & startdate &
"),--(A2:A100<=--""2005-06-30""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")

HTH,
Bernie
MS Excel MVP


"Jimbo" wrote in message
...
Many thanks for your help in previous thread,

Now I would like to replace some of the criteria with variables but I am
stumped with the dates ... e.g. in the code below I would like to

replace
"2005-06-01" with StartDate a variable which holds the value of the

first
day of the current month

StartDate = Format(DateAdd("d", -Day(Now() - 1), Now()), "yyyy-mm-dd")

However many permutations of Cdate, Cstr, Format etc I cannot get it to

work
correctly would you mind showing me how it can be done

........... original code ............



evaluate("SUMPRODUCT(--(A2:A100=--""2005-06-01""),--(A2:A100<=--""2005-06-3
0""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")


Thanks again






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default PING ... Bob Philips

Thanks for your input Bernie ... I had tried that approach prior to starting
this thread but it doesn't appear to work ...
... hence my fiddling about with Format, Cdate, Cstr etc since the original
code (which works) contains a string representing the first of June 2005
albeit in yyyy-mm-dd format.
Where am I goijng wrong ?

Regards
Jimbo

I always seem to have trouble with dates ...



"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Jimbo,

The correct way to do that is:

MsgBox Evaluate("SUMPRODUCT(--(A2:A100=--" & startdate &
"),--(A2:A100<=--""2005-06-30""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")

HTH,
Bernie
MS Excel MVP


"Jimbo" wrote in message
...
Many thanks for your help in previous thread,

Now I would like to replace some of the criteria with variables but I am
stumped with the dates ... e.g. in the code below I would like to replace
"2005-06-01" with StartDate a variable which holds the value of the first
day of the current month

StartDate = Format(DateAdd("d", -Day(Now() - 1), Now()), "yyyy-mm-dd")

However many permutations of Cdate, Cstr, Format etc I cannot get it to

work
correctly would you mind showing me how it can be done

........... original code ............


evaluate("SUMPRODUCT(--(A2:A100=--""2005-06-01""),--(A2:A100<=--""2005-06-3
0""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")


Thanks again






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default PING ... Bob Philips

Jimbo, my mistake (and an under-estimate by a few billion brain cells - as
Bernie has kindly confirmed.....!)

If I understand correctly, replace your ""2005-06-30"" with

" & StartDate & "

Then copy the following into a standard module.....

Function StartDate() As String
StartDate = Format(Date - Day(Date) + 1, "yyyy-mm-dd")
End Function

Then, for EndDate:

Function EndDate() As String
If Month(Date) = 12 Then
EndDate = Year(Date) + 1 & "-01-" & Format(Day(Date - Day(Date)
+ 1), "00")
Else
EndDate = Year(Date) & "-" & Format(Month(Date) + 1, "00") & "-"
& Format(Day(Date - Day(Date) + 1), "00")
End If
EndDate = CDate(EndDate) - 1
MsgBox EndDate
End Function


HTH
Roger




"Jimbo" wrote in message
...
Roger,
I'm not sure what you are suggesting ... Did you intend that your code was
to be used to establish the value of the variable StartDate or as a direct
substitute in the line of vbaCode.

In either case I would be grateful if you would reproduce the code and
also the equivalent for a variable EndDate (the end of current month)

My apologies if I am appearring negative or 'thick' its because I'm
becoming more confused by the hour

Regards



"Roger Whitehead" wrote in message
...
=Date - Day(Date) + 1


--
HTH
Roger
Shaftesbury (UK)
(A few miles further north than Bob P, and a few billion less brain
cells)



"Jimbo" wrote in message
...
Many thanks for your help in previous thread,

Now I would like to replace some of the criteria with variables but I am
stumped with the dates ... e.g. in the code below I would like to
replace "2005-06-01" with StartDate a variable which holds the value of
the first day of the current month

StartDate = Format(DateAdd("d", -Day(Now() - 1), Now()), "yyyy-mm-dd")

However many permutations of Cdate, Cstr, Format etc I cannot get it to
work correctly would you mind showing me how it can be done

........... original code ............

evaluate("SUMPRODUCT(--(A2:A100=--""2005-06-01""),--(A2:A100<=--""2005-06-30""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")


Thanks again








  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default PING ... Bob Philips

Sorry, that's:

Sorry, that's:

Function EndDate() As String
If Month(Date) = 12 Then
EndDate = Year(Date) + 1 & "-01-" & Format(Day(Date - Day(Date)
+ 1), "00")
Else
EndDate = Year(Date) & "-" & Format(Month(Date) + 1, "00") & "-"
& Format(Day(Date - Day(Date) + 1), "00")
End If
EndDate = CDate(EndDate) - 1
EndDate = Format(EndDate, "yyyy-mm-dd")
End Function

Watch out for the wrap

Roger

"Jimbo" wrote in message
...
Roger,
I'm not sure what you are suggesting ... Did you intend that your code was
to be used to establish the value of the variable StartDate or as a direct
substitute in the line of vbaCode.

In either case I would be grateful if you would reproduce the code and
also the equivalent for a variable EndDate (the end of current month)

My apologies if I am appearring negative or 'thick' its because I'm
becoming more confused by the hour

Regards



"Roger Whitehead" wrote in message
...
=Date - Day(Date) + 1


--
HTH
Roger
Shaftesbury (UK)
(A few miles further north than Bob P, and a few billion less brain
cells)



"Jimbo" wrote in message
...
Many thanks for your help in previous thread,

Now I would like to replace some of the criteria with variables but I am
stumped with the dates ... e.g. in the code below I would like to
replace "2005-06-01" with StartDate a variable which holds the value of
the first day of the current month

StartDate = Format(DateAdd("d", -Day(Now() - 1), Now()), "yyyy-mm-dd")

However many permutations of Cdate, Cstr, Format etc I cannot get it to
work correctly would you mind showing me how it can be done

........... original code ............

evaluate("SUMPRODUCT(--(A2:A100=--""2005-06-01""),--(A2:A100<=--""2005-06-30""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")


Thanks again








  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default PING ... Bob Philips

Jimbo,

The code worked for me in both its forms. I will send you a working version
privately.

HTH,
Bernie
MS Excel MVP


"Jimbo" wrote in message
...
Thanks for your input Bernie ... I had tried that approach prior to

starting
this thread but it doesn't appear to work ...
... hence my fiddling about with Format, Cdate, Cstr etc since the

original
code (which works) contains a string representing the first of June 2005
albeit in yyyy-mm-dd format.
Where am I goijng wrong ?

Regards
Jimbo

I always seem to have trouble with dates ...



"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Jimbo,

The correct way to do that is:

MsgBox Evaluate("SUMPRODUCT(--(A2:A100=--" & startdate &
"),--(A2:A100<=--""2005-06-30""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")

HTH,
Bernie
MS Excel MVP


"Jimbo" wrote in message
...
Many thanks for your help in previous thread,

Now I would like to replace some of the criteria with variables but I

am
stumped with the dates ... e.g. in the code below I would like to

replace
"2005-06-01" with StartDate a variable which holds the value of the

first
day of the current month

StartDate = Format(DateAdd("d", -Day(Now() - 1), Now()), "yyyy-mm-dd")

However many permutations of Cdate, Cstr, Format etc I cannot get it to

work
correctly would you mind showing me how it can be done

........... original code ............



evaluate("SUMPRODUCT(--(A2:A100=--""2005-06-01""),--(A2:A100<=--""2005-06-3
0""),
--(F2:F100=""Cleared""),--(D2:D1000),D2:D100)")


Thanks again








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
min IF - Bob Philips follow up John Excel Worksheet Functions 2 March 28th 07 01:58 AM
min IF - Bob Philips follow up Toppers Excel Worksheet Functions 0 March 28th 07 12:03 AM
Macro Modification - Bob Philips Are You Out There ? Carl Excel Worksheet Functions 2 September 17th 06 01:56 PM
Formatting Postcodes in VBA (Bob Philips, Myrna Larson + Jamie Collins?) Scott Excel Programming 7 March 18th 05 05:34 PM
Repost: Worksheet Change Method (Bob Philips, Ron De Bruin) Michael[_11_] Excel Programming 2 August 8th 03 01:16 PM


All times are GMT +1. The time now is 06:12 AM.

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"