Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
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()


Sheets("Data").Range("R4").Select
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.
Reply
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 11:43 AM
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 01: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 04:35 AM


All times are GMT +1. The time now is 03:27 PM.

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

About Us

"It's about Microsoft Excel"