Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Macro to add row with sequential numbers

I am trying too create a macro that will add rows that have a sequential
number assigned to them.

The finish product has an "add row" button that copies weeks and adds them
to the bottom of the sheet with an assigned number (i.e. Week 1, Week 2,
ect.).

I was able to add the rows with a macro that, copies and inserts row, but
cannot get the numbering to remain relative. (Even with relative reference
picked).

If anyone can help me out it would be much appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Macro to add row with sequential numbers

what are the appropriate lines in the macro you use?

"MechEng" wrote:

I am trying too create a macro that will add rows that have a sequential
number assigned to them.

The finish product has an "add row" button that copies weeks and adds them
to the bottom of the sheet with an assigned number (i.e. Week 1, Week 2,
ect.).

I was able to add the rows with a macro that, copies and inserts row, but
cannot get the numbering to remain relative. (Even with relative reference
picked).

If anyone can help me out it would be much appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Macro to add row with sequential numbers

I just recorded the macro by copiying the lines and inserted copied cells,
the following code was created:

Sub Add_Week()
ActiveCell.Offset(-11, 0).Rows("1:2").EntireRow.Select
Selection.Copy
ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
ActiveSheet.Paste
ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
ActiveSheet.Paste
ActiveCell.Offset(2, 0).Range("A1").Select
Application.CutCopyMode = False
End Sub


"bj" wrote:

what are the appropriate lines in the macro you use?

"MechEng" wrote:

I am trying too create a macro that will add rows that have a sequential
number assigned to them.

The finish product has an "add row" button that copies weeks and adds them
to the bottom of the sheet with an assigned number (i.e. Week 1, Week 2,
ect.).

I was able to add the rows with a macro that, copies and inserts row, but
cannot get the numbering to remain relative. (Even with relative reference
picked).

If anyone can help me out it would be much appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,942
Default Macro to add row with sequential numbers

hi,
Your second post confused me. from your first post i assumed that you just
want to know how to add week 3 to a line below week 2. i copied your code and
ran it on my PC. makes no sense. I think you need to refine it some more.
but to answer your first question...i think.....
If your are sitting in a blank cell just below the cell that has Week 2 in
it, this code sniplet will put Week 3 in the blank activecell.

ActiveCell.Value = Mid(ActiveCell.Offset(-1, 0), 1, 4) _
& " " & Mid(ActiveCell.Offset(-1, 0), 5, 6) + 1

regards
FSt1

"MechEng" wrote:

I just recorded the macro by copiying the lines and inserted copied cells,
the following code was created:

Sub Add_Week()
ActiveCell.Offset(-11, 0).Rows("1:2").EntireRow.Select
Selection.Copy
ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
ActiveSheet.Paste
ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
ActiveSheet.Paste
ActiveCell.Offset(2, 0).Range("A1").Select
Application.CutCopyMode = False
End Sub


"bj" wrote:

what are the appropriate lines in the macro you use?

"MechEng" wrote:

I am trying too create a macro that will add rows that have a sequential
number assigned to them.

The finish product has an "add row" button that copies weeks and adds them
to the bottom of the sheet with an assigned number (i.e. Week 1, Week 2,
ect.).

I was able to add the rows with a macro that, copies and inserts row, but
cannot get the numbering to remain relative. (Even with relative reference
picked).

If anyone can help me out it would be much appreciated.

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Macro to add row with sequential numbers

Hey FSt1, let me try to explain what I'm trying to do.

We have 4 rows of data grouped under a heading as week 1, 2, ect..
We want to add the next week (same four rows, new heading) at the bottom of
the page (next blank row).
The new week added could be blank or a copy of another, it doesn't matter.
Also we would prefer the user does not have to be in the active cell the
rows will be pasted into.
Also we will want to be able to remove the last week as well, as a seperate
macro.
We will use "Add_WeeK" and "Remove_Week" bottons to assign the macros too.

Hope this explains what I'm trying to achieve and that you can provide some
direction. Thanks in advance.

"FSt1" wrote:

hi,
Your second post confused me. from your first post i assumed that you just
want to know how to add week 3 to a line below week 2. i copied your code and
ran it on my PC. makes no sense. I think you need to refine it some more.
but to answer your first question...i think.....
If your are sitting in a blank cell just below the cell that has Week 2 in
it, this code sniplet will put Week 3 in the blank activecell.

ActiveCell.Value = Mid(ActiveCell.Offset(-1, 0), 1, 4) _
& " " & Mid(ActiveCell.Offset(-1, 0), 5, 6) + 1

regards
FSt1

"MechEng" wrote:

I just recorded the macro by copiying the lines and inserted copied cells,
the following code was created:

Sub Add_Week()
ActiveCell.Offset(-11, 0).Rows("1:2").EntireRow.Select
Selection.Copy
ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
ActiveSheet.Paste
ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
ActiveSheet.Paste
ActiveCell.Offset(2, 0).Range("A1").Select
Application.CutCopyMode = False
End Sub


"bj" wrote:

what are the appropriate lines in the macro you use?

"MechEng" wrote:

I am trying too create a macro that will add rows that have a sequential
number assigned to them.

The finish product has an "add row" button that copies weeks and adds them
to the bottom of the sheet with an assigned number (i.e. Week 1, Week 2,
ect.).

I was able to add the rows with a macro that, copies and inserts row, but
cannot get the numbering to remain relative. (Even with relative reference
picked).

If anyone can help me out it would be much appreciated.

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
Sequential Numbers Scott Hemphill Excel Worksheet Functions 8 August 6th 07 03:38 PM
Macro that Fills Sequential numbers David A. Excel Worksheet Functions 3 July 14th 07 07:03 AM
Sequential Numbers abcdexcel Excel Discussion (Misc queries) 3 January 18th 06 11:06 AM
sequential numbers Harley Excel Worksheet Functions 1 January 12th 06 09:57 PM
sequential numbers AndrewRichardWood Excel Discussion (Misc queries) 2 July 20th 05 05:00 PM


All times are GMT +1. The time now is 04:42 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"