Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Number Cells As Cell Value Changes, Excel 2000 & 2003

Hello,

My worksheet is setup with 3 columns multiple rows varying in length.
Example:

Col-1 Col-2 Col-3
AIR COMP AIR COMPRESSOR
CONVEYORS CONVEYORS
DKFTN DRINKING FOUNTAIN
DKFTN DRINKING FOUNTAIN
DOM TK-EL HOT WATER TANK-ELEC
EMER LIGHT EMERGENCY LIGHT
EMER LIGHT EMERGENCY LIGHT
EMER LIGHT EMERGENCY LIGHT

I would like number Col-1 in this format:

Col-1 Col-2 Col-3
001 AIR COMP AIR COMPRESSOR
001 CONVEYORS CONVEYORS
001 DKFTN DRINKING FOUNTAIN
002 DKFTN DRINKING FOUNTAIN
001 DOM TK-EL HOT WATER TANK-ELEC
001 EMER LIGHT EMERGENCY LIGHT
002 EMER LIGHT EMERGENCY LIGHT
003 EMER LIGHT EMERGENCY LIGHT

Some of my worksheets have a lot of data and i would like to use a
macro to insert the number for each item as example describes above.

Thank you for your help,
jfcby

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Number Cells As Cell Value Changes, Excel 2000 & 2003

I put the data in B1:Cxxx.
Then formatted column A with a custom format of 000
(format|cells|number tab|custom category|000)

Then I put 1 in A1
and this in A2:
=IF(B2=B1,A1+1,1)
and dragged down column A.

As a macro:

Option Explicit
sub testme
dim LastRow as long
with worksheets("sheet9999") 'change the name here
lastrow = .cells(.rows.count,"B").end(xlup).row
.range("a1").value = 1
with .range("a2:a" & lastrow)
.formulaR1C1 = "=IF(RC[1]=R[-1]C[1],R[-1]C+1,1)"
.value = .value
end with
.range("a:a").numberformat = "000"
end with
end sub



jfcby wrote:

Hello,

My worksheet is setup with 3 columns multiple rows varying in length.
Example:

Col-1 Col-2 Col-3
AIR COMP AIR COMPRESSOR
CONVEYORS CONVEYORS
DKFTN DRINKING FOUNTAIN
DKFTN DRINKING FOUNTAIN
DOM TK-EL HOT WATER TANK-ELEC
EMER LIGHT EMERGENCY LIGHT
EMER LIGHT EMERGENCY LIGHT
EMER LIGHT EMERGENCY LIGHT

I would like number Col-1 in this format:

Col-1 Col-2 Col-3
001 AIR COMP AIR COMPRESSOR
001 CONVEYORS CONVEYORS
001 DKFTN DRINKING FOUNTAIN
002 DKFTN DRINKING FOUNTAIN
001 DOM TK-EL HOT WATER TANK-ELEC
001 EMER LIGHT EMERGENCY LIGHT
002 EMER LIGHT EMERGENCY LIGHT
003 EMER LIGHT EMERGENCY LIGHT

Some of my worksheets have a lot of data and i would like to use a
macro to insert the number for each item as example describes above.

Thank you for your help,
jfcby


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Number Cells As Cell Value Changes, Excel 2000 & 2003

On Feb 7, 10:08 pm, Dave Peterson wrote:
I put the data in B1:Cxxx.
Then formatted column A with a custom format of 000
(format|cells|number tab|custom category|000)

Then I put 1 in A1
and this in A2:
=IF(B2=B1,A1+1,1)
and dragged down column A.

As a macro:

Option Explicit
sub testme
dim LastRow as long
with worksheets("sheet9999") 'change the name here
lastrow = .cells(.rows.count,"B").end(xlup).row
.range("a1").value = 1
with .range("a2:a" & lastrow)
.formulaR1C1 = "=IF(RC[1]=R[-1]C[1],R[-1]C+1,1)"
.value = .value
end with
.range("a:a").numberformat = "000"
end with
end sub





jfcby wrote:

Hello,


My worksheet is setup with 3 columns multiple rows varying in length.
Example:


Col-1 Col-2 Col-3
AIR COMP AIR COMPRESSOR
CONVEYORS CONVEYORS
DKFTN DRINKING FOUNTAIN
DKFTN DRINKING FOUNTAIN
DOM TK-EL HOT WATER TANK-ELEC
EMER LIGHT EMERGENCY LIGHT
EMER LIGHT EMERGENCY LIGHT
EMER LIGHT EMERGENCY LIGHT


I would like number Col-1 in this format:


Col-1 Col-2 Col-3
001 AIR COMP AIR COMPRESSOR
001 CONVEYORS CONVEYORS
001 DKFTN DRINKING FOUNTAIN
002 DKFTN DRINKING FOUNTAIN
001 DOM TK-EL HOT WATER TANK-ELEC
001 EMER LIGHT EMERGENCY LIGHT
002 EMER LIGHT EMERGENCY LIGHT
003 EMER LIGHT EMERGENCY LIGHT


Some of my worksheets have a lot of data and i would like to use a
macro to insert the number for each item as example describes above.


Thank you for your help,
jfcby


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Hello Dave,

Thank you for your help the code works great!

jfcby

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
Delete row if all cells are blank, Excel 2000 & 2003 [email protected] Excel Discussion (Misc queries) 1 December 14th 07 03:55 PM
Insert Data Last Row Loop through cells Excel 2000 & 2003 jfcby[_2_] Excel Programming 5 December 15th 06 05:28 PM
Does Excel 2000/2003 have a max number of records like '98 has? nobfelt Excel Discussion (Misc queries) 2 July 20th 06 01:27 PM
unlocked cells in excel 2000 now locked when opened in 2003 why? GallanH Excel Discussion (Misc queries) 4 August 31st 05 10:03 PM
In Excel 2000, Cannot edit cells in worksheet created in 2003? hbca4 Excel Discussion (Misc queries) 2 July 26th 05 06:21 PM


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