Macro help needed please!!

MPBJR

Board Regular
Joined
Mar 28, 2007
Messages
140
I have a macro that I'm trying to expand to do a little more for me. Here is my current macro that works fine:
Code:
Sub GetDateTime()
    Set Rng = Selection
    For Each c In Rng
        If c.Column = ActiveCell.Column Then
            c.Value = Date
            c.Offset(, 1).Value = Time
        End If
    Next c
    ActiveWorkbook.Save

Here is the additional code I will add:
Code:
Sub TIMESTAMP()
'
    Sheets("TIME STAMP").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
My question is, is it possible to have the number of copies that print in the second code change to match the amount of rows I select in the range of the first code?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
This should do it.
Code:
Sub GetDateTime() 
    Set Rng = Selection 
    x = Rng.Rows.Count
    For Each c In Rng 
        If c.Column = ActiveCell.Column Then 
            c.Value = Date 
            c.Offset(, 1).Value = Time 
        End If 
    Next c 

    ActiveWorkbook.Save
    Sheets("TIME STAMP").Select 
    ActiveWindow.SelectedSheets.PrintOut Copies:=x, Collate:=True
End Sub
 

Forum statistics

Threads
1,181,399
Messages
5,929,743
Members
436,687
Latest member
Glass of Gin

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
Top