ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding a new row in VB (https://www.excelbanter.com/excel-programming/411552-adding-new-row-vbulletin.html)

soph

Adding a new row in VB
 
Hi

I have a rolling data sheet which I need to update with the previous day's
data each morning. eg if today is the 03/05 then I add a new row today for
the 02/05. I would like to create a macro to copy the last row of data and
copy it down which should update the date. can anyone help me with how to do
this?

Greatly appreciated
Soph

Bob Phillips

Adding a new row in VB
 
Dim LastRow As Long

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

Rows(LastRow).Copy Cells(LastRow + 1, "A")
Cells(LastRow + 1, "A").Value = Cells(LastRow, "A") - 1


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"soph" wrote in message
...
Hi

I have a rolling data sheet which I need to update with the previous day's
data each morning. eg if today is the 03/05 then I add a new row today
for
the 02/05. I would like to create a macro to copy the last row of data
and
copy it down which should update the date. can anyone help me with how to
do
this?

Greatly appreciated
Soph





All times are GMT +1. The time now is 07:01 AM.

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