ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto Entering Dates Across Seven Worksheets and Navigating (https://www.excelbanter.com/excel-programming/399348-auto-entering-dates-across-seven-worksheets-navigating.html)

[email protected]

Auto Entering Dates Across Seven Worksheets and Navigating
 
Hello there,
In a workbook with 7 sheets (named Period 1, Period 2, ..., Period 7), I
would like to attach code to a macro that does the following:

1.) Go to the sheet named Period 1,

2.) Find the last used cell in row 12,

3.) Insert today's date into the next cell to the right (formatted mm/
dd/yy).

4.) Do this to all of the sheets whose name starts with "Period."

5.) Lastly, put the cursor 3 cells below the newly entered date on
the sheet named Period 1.

Thank you very much for any and all help on this code.
Tracy


JW[_2_]

Auto Entering Dates Across Seven Worksheets and Navigating
 
Sub this()
Dim ws As Worksheet, lCol As Integer, r As Long
r = 12
For Each ws In ActiveWorkbook.Worksheets
With ws
If Left(.Name, 6) = "Period" Then
lCol = .Cells(r, "IV") _
.End(xlToLeft).Column + 1
.Cells(r, lCol).NumberFormat = _
"mm/dd/yy;@"
.Cells(r, lCol).Value = Date
If .Name = "Period 1" Then _
Application.Goto .Cells(r + 3, lCol)
End If
End With
Next ws
End Sub

wrote:
Hello there,
In a workbook with 7 sheets (named Period 1, Period 2, ..., Period 7), I
would like to attach code to a macro that does the following:

1.) Go to the sheet named Period 1,

2.) Find the last used cell in row 12,

3.) Insert today's date into the next cell to the right (formatted mm/
dd/yy).

4.) Do this to all of the sheets whose name starts with "Period."

5.) Lastly, put the cursor 3 cells below the newly entered date on
the sheet named Period 1.

Thank you very much for any and all help on this code.
Tracy



[email protected]

Auto Entering Dates Across Seven Worksheets and Navigating
 
That's awesome. Thanks JW.



All times are GMT +1. The time now is 05:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com