#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Insert Row numbers

I'm trying to insert Item numbers in cells next to rows that have data in
the data column.

BEFORE AFTER

COL A Col A Col B
DATA ITEM DATA
99 1 99
98 2 98
97 3 97
84 4 84
34 5 34

The macro selects the proper numerical row value for FirstRow and LastRow,
inserts the Column name (Item) and inserts the series starting number ( 1 ),
but I get a global error for the Range statement, and the series doesn¹t
run.
How to change?



Sub AddItemNumber()


Cells.Find(What:="Date", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
LastRow = ActiveCell.End(xlDown).Row
ActiveCell.EntireColumn.Insert

ActiveCell.Value = "Item"
ActiveCell.Offset(1).Value = 1
FirstRow = ActiveCell.Row + 1

Range("FirstRow" & "LastRow").Select
ŒRange(³FirstRow:LastRow²).Select

ActiveCell.DataSeries Rowcol:=xlColumns, _
Type:=xlLinear, Date:=xlDay, Step:=1, Trend:=False

End Sub





  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Insert Row numbers

hi
i don't see in your code where you set firstrow and lastrow but if you have
just posted part of your code and have set firstrow and lastrow then this
might work better......
Range(firstrow, lastrow).Select

regards
FSt1
"Gene Augustin" wrote:

I'm trying to insert Item numbers in cells next to rows that have data in
the data column.

BEFORE AFTER

COL A Col A Col B
DATA ITEM DATA
99 1 99
98 2 98
97 3 97
84 4 84
34 5 34

The macro selects the proper numerical row value for FirstRow and LastRow,
inserts the Column name (Item) and inserts the series starting number ( 1 ),
but I get a global error for the Range statement, and the series doesn¹t
run.
How to change?



Sub AddItemNumber()


Cells.Find(What:="Date", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
LastRow = ActiveCell.End(xlDown).Row
ActiveCell.EntireColumn.Insert

ActiveCell.Value = "Item"
ActiveCell.Offset(1).Value = 1
FirstRow = ActiveCell.Row + 1

Range("FirstRow" & "LastRow").Select
ŒRange(³FirstRow:LastRow²).Select

ActiveCell.DataSeries Rowcol:=xlColumns, _
Type:=xlLinear, Date:=xlDay, Step:=1, Trend:=False

End Sub





  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Insert Row numbers

range(firstrow & ":" & lastrow).select

By the way, these newsgroups are plain text only--no attachments and no
HTML/rich text.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Insert Row numbers

Excel 2004 for MAC, MAC Powerbook G4, OS 10.5.6

Here's the code again. Sorry, I didn't know about "no html" in posts.
I commented the code as to what is happening. Both recommended Range
statements fail.

Sub AddItemNumber()


Cells.Find(What:="Date", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
LastRow = ActiveCell.End(xlDown).Row - 1 'gives blank sell row - 1
ActiveCell.EntireColumn.Insert

ActiveCell.Value = "Item" 'lable ITEM in cell
ActiveCell.Offset(1).Value = 1 ' move active cell down 1
firstrow = ActiveCell.Row + 1 'row first cell ITEM + 1

Range(firstrow & ":" & LastRow).Select ' causes entire rows with
data to be selected
'Range(firstrow, LastRow).Select 'error: Method 'Range of
Object'_Global' failed

ActiveCell.DataSeries Rowcol:=xlColumns, _
Type:=xlLinear, Date:=xlDay, Step:=1, Trend:=False

End Sub





On 2/23/09 9:37 PM, in article
, "FSt1"
wrote:

hi
i don't see in your code where you set firstrow and lastrow but if you have
just posted part of your code and have set firstrow and lastrow then this
might work better......
Range(firstrow, lastrow).Select

regards
FSt1
"Gene Augustin" wrote:

I'm trying to insert Item numbers in cells next to rows that have data in
the data column.

BEFORE AFTER

COL A Col A Col B
DATA ITEM DATA
99 1 99
98 2 98
97 3 97
84 4 84
34 5 34

The macro selects the proper numerical row value for FirstRow and LastRow,
inserts the Column name (Item) and inserts the series starting number ( 1 ),
but I get a global error for the Range statement, and the series doesn¹t
run.
How to change?



Sub AddItemNumber()


Cells.Find(What:="Date", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
LastRow = ActiveCell.End(xlDown).Row
ActiveCell.EntireColumn.Insert

ActiveCell.Value = "Item"
ActiveCell.Offset(1).Value = 1
FirstRow = ActiveCell.Row + 1

Range("FirstRow" & "LastRow").Select
ŒRange(³FirstRow:LastRow²).Select

ActiveCell.DataSeries Rowcol:=xlColumns, _
Type:=xlLinear, Date:=xlDay, Step:=1, Trend:=False

End Sub







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 to insert same row numbers in several function statement David Biddulph[_2_] Excel Discussion (Misc queries) 0 August 21st 08 11:05 AM
how do I insert Item numbers EJ Jacques Excel Discussion (Misc queries) 1 May 24th 08 12:30 AM
Insert spaces in String of Numbers Marianne Excel Worksheet Functions 1 August 25th 06 06:32 PM
how to insert page numbers Mylo Excel Discussion (Misc queries) 1 August 5th 05 11:19 AM
how do I insert an ' in front of many rows of numbers? jnycks Excel Discussion (Misc queries) 2 April 25th 05 02:48 PM


All times are GMT +1. The time now is 02:32 AM.

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

About Us

"It's about Microsoft Excel"