Macro help needed please!!

MPBJR

Board Regular
Joined
Mar 28, 2007
Messages
143
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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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