View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default A little more effort...

You want the number of cells:

Sub AAtester10()
Dim sStart As String, sEnd As String
Dim res As Variant, res1 As Variant
Dim rng As Range
sStart = InputBox("Enter Start Date")
sEnd = InputBox("Enter End Date")

If IsDate(sStart) And IsDate(sEnd) Then
res = Application.Match(CLng(CDate(sStart)), Range("A1:A365"), 0)
res1 = Application.Match(CLng(CDate(sEnd)), Range("A1:A365"), 0)
If Not IsError(res) And Not IsError(res1) Then
Set rng = Range(Range("A1:A365")(res), Range("A1:A365")(res1))
rng.Resize(, 6).BorderAround Weight:=xlMedium, ColorIndex:=3
msgbox "Number of cells in " & rng.Address & " is " & rng.count
End If
End If
End Sub

--
Regards,
Tom Ogilvy


"darno " wrote in message
...
Dear TOM,

If you remember that the solution given under was recommended by you
and which worked great for my query. Now a little more help is
required, I am sure (100%) you will be able to answer this as well.

In the same query I want to get the total of my date range Column. As
this is understood that the 2 input dates that are entered do not have
a limit they can be based on any starting cell to any ending cell. So
my query is to calculate no of cells used between these 2 dates
including starting and ending date as well. for example the column2
contains all date entries. If the first date that I entered in input
box was on cell b2 and the end date was on b30 then I want to to know
that how many total no of cells are there between these two dates. In
simple words I need the total SUM of those cells used in from starting
date to ending date..


<<<OLD MACRO

Sub AAtester10()
Dim sStart As String, sEnd As String
Dim res As Variant, res1 As Variant
Dim rng As Range
sStart = InputBox("Enter Start Date")
sEnd = InputBox("Enter End Date")

If IsDate(sStart) And IsDate(sEnd) Then
res = Application.Match(CLng(CDate(sStart)), Range("A1:A365"), 0)
res1 = Application.Match(CLng(CDate(sEnd)), Range("A1:A365"), 0)
If Not IsError(res) And Not IsError(res1) Then
Set rng = Range(Range("A1:A365")(res), Range("A1:A365")(res1))
rng.Resize(, 6).BorderAround Weight:=xlMedium, ColorIndex:=3
End If
End If
End Sub


By the way i did post the same message in my previous thread but no
response thats why i am writing it in a new thread.


Regards,


Darno


---
Message posted from http://www.ExcelForum.com/