Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto Serial Number Using VBA


Hi all,

I use the following formula to get an Auto Serial Number for all cell
in column A.


Code
-------------------
=IF(B2<"",ROW()-1,""
-------------------


My question is how can I get an Auto Serial Number for all cells i
column A by using VBA.

I hope that my quesion is clear,

Thank you

--
LoveCandl
-----------------------------------------------------------------------
LoveCandle's Profile: http://www.excelforum.com/member.php...fo&userid=2861
View this thread: http://www.excelforum.com/showthread.php?threadid=48756

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Auto Serial Number Using VBA

Here's one way: (In a standard module)

Sub Foo()
Range("B2").Select
lrow = Cells(Rows.Count, 2).End(xlUp).Row
Set myrange = Range(Cells(2, 2), Cells(lrow, 2))
For Each cell In myrange
cell.Offset(0, -1).Value = i + 1
i = i + 1
Next cell
End Sub





"LoveCandle" wrote
in message ...

Hi all,

I use the following formula to get an Auto Serial Number for all cells
in column A.


Code:
--------------------
=IF(B2<"",ROW()-1,"")
--------------------


My question is how can I get an Auto Serial Number for all cells in
column A by using VBA.

I hope that my quesion is clear,

Thank you,


--
LoveCandle
------------------------------------------------------------------------
LoveCandle's Profile:
http://www.excelforum.com/member.php...o&userid=28612
View this thread: http://www.excelforum.com/showthread...hreadid=487565



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Auto Serial Number Using VBA

Is this what you want

For i = 2 To Cells(Rows.Count,"B").End(xlUp).Row
If Cells(i,"B").Value < "" Then
Cells(i,"A").Value = i - 1
End If
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"LoveCandle" wrote
in message ...

Hi all,

I use the following formula to get an Auto Serial Number for all cells
in column A.


Code:
--------------------
=IF(B2<"",ROW()-1,"")
--------------------


My question is how can I get an Auto Serial Number for all cells in
column A by using VBA.

I hope that my quesion is clear,

Thank you,


--
LoveCandle
------------------------------------------------------------------------
LoveCandle's Profile:

http://www.excelforum.com/member.php...o&userid=28612
View this thread: http://www.excelforum.com/showthread...hreadid=487565



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
Serial Number Fareez Excel Worksheet Functions 8 January 24th 09 11:50 PM
Look up part of a number within a serial number and cpy back assoc Seantastic Excel Worksheet Functions 9 November 3rd 08 04:10 PM
macro to add an auto serial number column Blubber Excel Discussion (Misc queries) 3 October 24th 08 09:36 AM
Auto Serial No Abdul Shakeel Excel Discussion (Misc queries) 1 October 17th 08 12:11 PM
Insert auto serial number in Excel template Van Gel Excel Programming 1 February 18th 05 01:33 PM


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