Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default formula problem

If I have data laid out as follows

Col1 Col2 Col3 Col4
Name1 111 tyr uuu
Name1 222 tyr uuu
Name1 333 tyr uuu
Name2 111 tyr uuu
Name2 222 tyr uuu
Name3 111 tyr uuu
Name4 111 tyr uuu
Name4 222 tyr uuu

How can I use a formula in a new column to get the
following output

Col1 Col2 Col3 Col4 Col5
1 Name1 111 tyr uuu
1 Name1 222 tyr uuu
1 Name1 333 tyr uuu
2 Name2 111 tyr uuu
2 Name2 222 tyr uuu
3 Name3 111 tyr uuu
4 Name4 111 tyr uuu
4 Name4 222 tyr uuu

the name in the above column 2 will always be the same
they will always be in consecutive rows as I will sort
first.

I dont know if this is possible but if it is it will save
me a lot of time :-

Andrew
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default formula problem

Hi Andrew,

Assuming your data starts in B2, and A1 is not a number, enter this in
A2 and copy it down.

=IF(B2=B1,A1,A1+1)

Hope this works for you,

Gary

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default formula problem

Hi Andrew,
I am not certain that this will accomplish what you need, but it appears
that you want to put a count in column A. This will number the names,
assuming the names are grouped and sorted.

Sub Macro1()
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
ActiveCell.FormulaR1C1 = "No"
Range("A2").Select
ActiveCell.Value = 1
Ct = 1
Do Until ActiveCell.Offset(0, 1).Value = ""
No1 = ActiveCell.Offset(0, 1).Value
No2 = ActiveCell.Offset(1, 1).Value
NoMinus = ActiveCell.Offset(-1, 1).Value
If ActiveCell.Address = "$A$2" Then ActiveCell.Value = 1:
ActiveCell.Offset(1, 0).Select: GoTo Bottomloop
If No1 = No2 Then
If No1 = NoMinus Then
ActiveCell.Value = Ct
Else
ActiveCell.Value = Ct
End If
Else
If No1 = NoMinus Then
ActiveCell.Value = Ct
Ct = Ct + 1
Else
ActiveCell.Value = Ct
Ct = Ct + 1
End If
End If
ActiveCell.Offset(1, 0).Select
Bottomloop:
Loop
End Sub

Thanks,

"Andrew" wrote:

If I have data laid out as follows

Col1 Col2 Col3 Col4
Name1 111 tyr uuu
Name1 222 tyr uuu
Name1 333 tyr uuu
Name2 111 tyr uuu
Name2 222 tyr uuu
Name3 111 tyr uuu
Name4 111 tyr uuu
Name4 222 tyr uuu

How can I use a formula in a new column to get the
following output

Col1 Col2 Col3 Col4 Col5
1 Name1 111 tyr uuu
1 Name1 222 tyr uuu
1 Name1 333 tyr uuu
2 Name2 111 tyr uuu
2 Name2 222 tyr uuu
3 Name3 111 tyr uuu
4 Name4 111 tyr uuu
4 Name4 222 tyr uuu

the name in the above column 2 will always be the same
they will always be in consecutive rows as I will sort
first.

I dont know if this is possible but if it is it will save
me a lot of time :-

Andrew

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
Formula Problem mjones Excel Worksheet Functions 2 July 30th 11 05:55 PM
IF-Then formula problem Bill Elerding Excel Worksheet Functions 6 March 25th 08 10:00 AM
Formula Problem Mark Hanson Excel Discussion (Misc queries) 2 September 12th 07 05:17 PM
Formula problem Computer geek Excel Worksheet Functions 4 June 8th 07 08:01 PM
Formula problem Dave Excel Discussion (Misc queries) 3 January 30th 07 10:58 PM


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