Select a range of cells based on system date

manojrf

Board Regular
Joined
Mar 28, 2011
Messages
109
Hi,

I have a worksheet which has today's date in column D , if there is data in column A , by giving the IF formula and by the formula =today() . In columns A , B and C some other data are entered. Suppose I enter data from A1 to C10 , I would like to like to select the cells entered today , to be printed automatically by the help of a macro. If I enter some more data tomorrow from A11 to C15, I would like to print only A11 to C15 .

In this worksheet, when I save the file can the date be saved , so that when I open it some other day the saved portion ( date ) doesn't change ?

Can anyone help me ?

Thanks in advance,

Manuel Z G
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi Manuel,

Copy the following code into the object of the sheet were columns A:D are in.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A1:c1000")) Is Nothing Then
    Range("D" & Target.Row).Value = Date
End If

End Sub

Success
 
Upvote 0
Hi WinteE,

The one you have sent me ,works fine. Superb !!! .Thanks a lot. I had asked one more thing. Could you please help me on that ?

I have a worksheet which has today's date in column D . (The one you sent me works fine. ) In columns A , B and C some other data are entered. Suppose I enter data from A1 to C10 , I would like to like to select the cells entered today , to be printed automatically by the help of a macro button. To make it some more clear what I need is, when I click the print macro button, the cells entered today has to selected and printed automatically. If I enter some more data tomorrow from A11 to C15, I would like to print only A11 to C15 tomorrow.

Could you help me please ?

Regards, Manuel
 
Upvote 0
Hi Manuel,

Add the code below to the object of the sheet :

Code:
Sub PrintToday()

i = Cells(Cells.Rows.Count, "B").End(xlUp).Row

For Each c In Range("D1:D" & i)
    If c.Value = Date Then
        CountVal = CountVal + 1
        If CountVal = 1 Then
            StartRow = c.Row
        Else
            EndRow = c.Row
        End If
    End If
Next c

Range("A" & StartRow & ":D" & EndRow).Select
Selection.PrintOut Copies:=1, Collate:=True

End Sub

Success

Erik
 
Upvote 0
Hi WinteE,

Thank you,thanks a lot for the one you sent me. It works superb !!!!! Thank you once again.

Regards, Manuel
 
Upvote 0
Hi WinteE,

What changes should I make , if the date column is changed to E from D ? I would like to print A : D .

Can you help me ?

Manuel
 
Upvote 0
Hi Manuel,

You'll have to make adjustments to both macro's, I've marked the changes bold.

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A1:D1000")) Is Nothing Then
    Range("E" & Target.Row).Value = Date
End If

End Sub

Rich (BB code):
Sub PrintToday()

i = Cells(Cells.Rows.Count, "B").End(xlUp).Row

For Each c In Range("E1:E" & i)
    If c.Value = Date Then
        CountVal = CountVal + 1
        If CountVal = 1 Then
            StartRow = c.Row
        Else
            EndRow = c.Row
        End If
    End If
Next c

Range("A" & StartRow & ":D" & EndRow).Select
Selection.PrintOut Copies:=1, Collate:=True

End Sub

Success,
Erik
 
Upvote 0
Hi WinteE,

I found out by myself the changes to be made. Sorry to bother you.

Anyway thank you so much.

Regards,

Manuel
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top