Current date code

cns324

New Member
Joined
Jan 21, 2022
Messages
37
Office Version
  1. 365
Platform
  1. Windows
Hello, I have the below code that adds today's date to the 1st column, then deletes some other columns. The issue is the current date is being added to 50K lines and not just the lines that have data, which is approx 100.
How can this be fixed to where only the rows with data has the date added? Thank you for the help.

Sub Step1()

Range("A1").Select

ActiveCell.FormulaR1C1 = "Date"

Range("A2").Select

ActiveCell.FormulaR1C1 = "=TODAY()"

Range("A2").Select

Selection.Copy

Selection.PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _

:=False, Transpose:=False

Range("A2").Select

Application.CutCopyMode = False

Selection.Copy

Range("A3").Select

Range(Selection, Selection.End(xlDown)).Select

Range(Selection, Selection.End(xlDown)).Select

ActiveSheet.paste

Range("B:B,C:C,H:H,I:I,L:L").Select

Range("L1").Activate

ActiveWindow.SmallScroll ToRight:=2

Range("B:B,C:C,H:H,I:I,L:L,M:M").Select

Range("M1").Activate

Application.CutCopyMode = False

Selection.Delete Shift:=xlToLeft

ActiveWindow.LargeScroll ToRight:=-1

Columns("A:A").ColumnWidth = 10

Range("A2").Select

End Sub
 

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.
What column of data can we look at to determine where the data ends?
 
Upvote 0
Column B can be used to determine where the data ends. Thanks
 
Upvote 0
This is the only line of code you should need to populate column A with the current date:
VBA Code:
    Range("A2:A" & Cells(Rows.Count, "B").End(xlUp).Row).Formula = "=TODAY()"
 
Upvote 0
Solution

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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