Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add row number in Excel


I have several spreadsheets that are converted in batch. The row coun
is never the same. I've tried to write some code that did no
reference a specific cell, but I'm having problems.

Here is what I have so far. The problem is the last cell is differen
in every file. I can do this with the row number in the A column, bu
I need it at the end of th spreadsheet.

- go to end row/column
- move one cell to the right
- enter row()
- copy row() from that cell to the top row in that column


ActiveCell.SpecialCells(xlLastCell).Select
Range("R4233").Select
ActiveCell.FormulaR1C1 = "=ROW()"
Range("R4233").Select
Selection.Copy
Range("R4232").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
Application.CutCopyMode = Fals

--
swtransactio
-----------------------------------------------------------------------
swtransaction's Profile: http://www.excelforum.com/member.php...fo&userid=3745
View this thread: http://www.excelforum.com/showthread.php?threadid=57137

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add row number in Excel


here we go, this works

'add row number at the end of the file
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=ROW()"
Selection.Copy
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste


--
swtransaction
------------------------------------------------------------------------
swtransaction's Profile: http://www.excelforum.com/member.php...o&userid=37459
View this thread: http://www.excelforum.com/showthread...hreadid=571370

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Add row number in Excel

I like to pick out a row/column that is always used when that row/column is
used.

For instance, if Row 1 has headers and column A always has something in it when
the row is used:

dim wks as worksheet
dim LastRow as long
dim LastCol as long

set wks = workbooks(...).worksheets(...)

with wks
lastrow = .cells(.rows.count,"A").end(xlup).row
lastcol = .cells(1,.columns.count).end(xltoleft).column

.range("A1",.cells(lastrow,lastcol)).copy _
destination:=whereeveryouwant

end with

swtransaction wrote:

I have several spreadsheets that are converted in batch. The row count
is never the same. I've tried to write some code that did not
reference a specific cell, but I'm having problems.

Here is what I have so far. The problem is the last cell is different
in every file. I can do this with the row number in the A column, but
I need it at the end of th spreadsheet.

- go to end row/column
- move one cell to the right
- enter row()
- copy row() from that cell to the top row in that column

ActiveCell.SpecialCells(xlLastCell).Select
Range("R4233").Select
ActiveCell.FormulaR1C1 = "=ROW()"
Range("R4233").Select
Selection.Copy
Range("R4232").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
Application.CutCopyMode = False

--
swtransaction
------------------------------------------------------------------------
swtransaction's Profile: http://www.excelforum.com/member.php...o&userid=37459
View this thread: http://www.excelforum.com/showthread...hreadid=571370


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Add row number in Excel

sub WriteRowforActiveCell()
cells(1,activecell.column).Value) = _
cells(rows.count,activecell.column).End(xlup)(2).R ow
End Sub

--
Regards,
Tom Ogilvy


"swtransaction" wrote:


I have several spreadsheets that are converted in batch. The row count
is never the same. I've tried to write some code that did not
reference a specific cell, but I'm having problems.

Here is what I have so far. The problem is the last cell is different
in every file. I can do this with the row number in the A column, but
I need it at the end of th spreadsheet.

- go to end row/column
- move one cell to the right
- enter row()
- copy row() from that cell to the top row in that column


ActiveCell.SpecialCells(xlLastCell).Select
Range("R4233").Select
ActiveCell.FormulaR1C1 = "=ROW()"
Range("R4233").Select
Selection.Copy
Range("R4232").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
Application.CutCopyMode = False


--
swtransaction
------------------------------------------------------------------------
swtransaction's Profile: http://www.excelforum.com/member.php...o&userid=37459
View this thread: http://www.excelforum.com/showthread...hreadid=571370


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 can I click on a telephone number in an Excel 2002 spreadsheet, and have the number dialed? jbclem Excel Discussion (Misc queries) 2 August 13th 09 01:57 AM
Excel. How to round a number to nearest half number? HaraldS Excel Discussion (Misc queries) 2 February 19th 07 09:50 AM
convert text-format number to number in excel 2000%3f Larry Excel Discussion (Misc queries) 1 July 29th 05 08:18 PM
excel format cells/Number/Category: Number problem Matts Excel Discussion (Misc queries) 5 December 9th 04 09:47 PM
command to return the row number or cell number in excel? desmondleow[_5_] Excel Programming 1 December 11th 03 10:51 AM


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