LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old October 15th 17, 08:31 PM posted to microsoft.public.excel.misc
external usenet poster
First recorded activity by ExcelBanter: Oct 2017
Posts: 1
Default Insert blank row in table using VBA and automatically populate active cell

Hi all,

I have the following VBA code that inserts a blank row at the top of the table and R4 then becomes the active cell.

Private Sub CommandButton1_Click()

ActiveCell.EntireRow.Insert Shift:=xlDown

Range("R4").HorizontalAlignment = xlCenter

End Sub

When inserting a new row, I would like to populate R4 with the year following the previous year which is then in cell R5.

For example:

Before VBA code is executed:
R4: 2014
R5: 2013
R6: 2012

After VBA code is executed:
R4: 2015
R5: 2014
R6: 2013
R7: 2012

These cells are formatted as text.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I insert a blank row when a value changes, automatically mb5451 Excel Worksheet Functions 3 December 22nd 08 12:43 PM
Start Cell B1 then find first blank cell, insert subtotal, next non blank, then next blank, sutotal cells in between......... [email protected][_2_] Excel Programming 2 June 7th 07 09:27 PM
How do I automatically insert a blank row between sets of data? usdivers Excel Discussion (Misc queries) 5 February 5th 07 02:45 PM
Populate current active cell - Help Please!! Larry Excel Worksheet Functions 0 July 19th 06 10:19 PM
automatically insert 8 blank rows between each record Evad Excel Discussion (Misc queries) 1 February 2nd 06 05:35 AM

All times are GMT +1. The time now is 07:18 PM.

Powered by vBulletin® Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright 2004-2020 ExcelBanter.
The comments are property of their posters.

About Us

"It's about Microsoft Excel"


Copyright © 2017