#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default adding row

hi. i have a spread sheet where i have to record some events.
the first row is already formatted and the first cell has a number 1.
i would like a macro to automatically create another line each time a press
a button and that would increase the number of the first cell from the
previous line.

a sheet like below:

number header2 header3
1 bla bla zzz zzzz
2 qwfjkd jjioeereorko
3 gdfgfgf frefsdfdf

i would like a macro that associated to a button automatically add a line
below the last one, keeping the same formatting of the cells and in the line
added increase the column "number" by 1

in order to have:

number header2 header3
1 bla bla zzz zzzz
2 qwfjkd jjioeereorko
3 gdfgfgf frefsdfdf
4



thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default adding row

To add a row you can use this code; but if you are looking at auto numbering
you can acheive this with a simple formula in column A =IF(B2<"",A1+1,"")

lngRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Rows(lngRow + 1).Insert
Cells(lngRow + 1, 1) = Cells(lngRow, 1) + 1


If this post helps click Yes
---------------
Jacob Skaria


"massi" wrote:

hi. i have a spread sheet where i have to record some events.
the first row is already formatted and the first cell has a number 1.
i would like a macro to automatically create another line each time a press
a button and that would increase the number of the first cell from the
previous line.

a sheet like below:

number header2 header3
1 bla bla zzz zzzz
2 qwfjkd jjioeereorko
3 gdfgfgf frefsdfdf

i would like a macro that associated to a button automatically add a line
below the last one, keeping the same formatting of the cells and in the line
added increase the column "number" by 1

in order to have:

number header2 header3
1 bla bla zzz zzzz
2 qwfjkd jjioeereorko
3 gdfgfgf frefsdfdf
4



thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default adding row

thanks!

"Jacob Skaria" wrote:

To add a row you can use this code; but if you are looking at auto numbering
you can acheive this with a simple formula in column A =IF(B2<"",A1+1,"")

lngRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Rows(lngRow + 1).Insert
Cells(lngRow + 1, 1) = Cells(lngRow, 1) + 1


If this post helps click Yes
---------------
Jacob Skaria


"massi" wrote:

hi. i have a spread sheet where i have to record some events.
the first row is already formatted and the first cell has a number 1.
i would like a macro to automatically create another line each time a press
a button and that would increase the number of the first cell from the
previous line.

a sheet like below:

number header2 header3
1 bla bla zzz zzzz
2 qwfjkd jjioeereorko
3 gdfgfgf frefsdfdf

i would like a macro that associated to a button automatically add a line
below the last one, keeping the same formatting of the cells and in the line
added increase the column "number" by 1

in order to have:

number header2 header3
1 bla bla zzz zzzz
2 qwfjkd jjioeereorko
3 gdfgfgf frefsdfdf
4



thanks

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
Adding 4 cells next to eachother and then adding the following fourcells [email protected] Excel Programming 3 May 29th 08 09:00 AM
Adding a new row in VB soph Excel Programming 1 May 27th 08 09:58 AM
adding some rows in the middle of adding some other rows Janis Excel Programming 3 October 4th 07 03:20 AM
Adding every 5th row (e.g. B5 + B10 + B15 etc) Shazzer Excel Discussion (Misc queries) 6 December 20th 06 08:00 PM
Adding Up! ExcelBob Excel Discussion (Misc queries) 2 June 14th 06 02:31 PM


All times are GMT +1. The time now is 10:28 AM.

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"