VBA Help - Error when sinlge line is added.

Trev0j

New Member
Joined
May 27, 2018
Messages
28
Good day..

Need help - Newbie in VBA coding.

have below code:

Columns("Z:Z").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
'Selection.Copy
Range("x3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 2).Range("A1").Select
Range(Selection, Selection.End(xlUp)).Select
Application.CutCopyMode = False
Selection.FillDown
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

Code is working fine when Multiple lines are added in a row.
hope to find working code when only single line is added.

thanks
 
Re: TODAY() - error for single row.

Presumably you have pasted some data to column X (and possibly other columns) and wish to put the date in column Z for the new data rows.
Based on the code you posted, I will assume that the pasted data is selected, so :

Code:
Intersect(Selection.EntireRow, [Z:Z]) = Date
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Re: TODAY() - error for single row.

thank you... it works also..
but i have codes before the one i posted thats why it is deselected.

Thank so much..
 
Upvote 0
Re: TODAY() - error for single row.

@Trev0j
Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. (rule 12 here: Forum Rules).
I have merged both your threads.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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