Date distinguish

  • Thread starter Thread starter hme
  • Start date Start date
H

hme

Hi every body

How does excel destinguish what date is today?

I use Excel as a scheduling program.
I have my daily schedule In *sheet1* with the the tasks and the the
duration (Start date and finish date)

I would like to have a macro to be able to distinguish what date is
today and copy all the tasks which are planned just for today in sheet1
(in Colomn A) and past them in column A in sheet2.For e.g. I would like
to see the tasks for 01/05/2006 in another sheet.

Thk
hme
 
Today's date is the Date function in VBA, so you would just do something
like

For this_row = 1 To last_row_number
If Cells(this_row,"A").Value = Date Then
j = j + 1
Cells(this_row,"A").Copy Worksheets("Sheet2").Range("A" & j)
End If
Next this_row

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Thank for prompt reply

I did not understand.

Requester Macro should find today date in sheet1 where there is all the
date from 1/1/2006 to 31/12/2006 and correspond task.

Later the task shoud be copy to sheet2.

thk

hme
 
Sub CopyData()
Dim this_row As Long
Dim last_row_number As Long
Dim start_date As Date
Dim end_date As Date
Dim j As Long

start_date = DateSerial(2006, 1, 1)
end_date = DateSerial(2006, 12, 31)
last_row_number = Cells(Rows.Count, "A").End(xlUp).Row
For this_row = 1 To last_row_number
If Cells(this_row, "A").Value >= start_date And _
Cells(this_row, "A").Value <= end_date Then
j = j + 1
Rows(this_row).Copy Worksheets("Sheet2").Range("A" & j)
End If
Next this_row
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Thanks Bob

I tried what you suggested and it is working very well.

Thanks again
hm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top