#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 126
Default formula or macro.

Hi,

the problem is need a formula or a macro for my excel 2003 work sheet.
this is part of my work sheet below:
column column
A B
-------------------------------
5 2

6 2

dog 1
dog 2
dog 1

that I want is, how to create a formula or macro to chane ( if column A is
dog, column B at the same row replace to T01 and by order(T02,T03) like
sample below

column column
A B
-------------------------------
9 2

10 2

dog T01
dog T02
dog T03

Regards
Johnny.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 638
Default formula or macro.

Assuming you don't have more than 100 consecutive occurrences of a
given item, the formula below will work.
=IF(ISBLANK(A2),"",IF(A2<A1,"T01","T" & TEXT(RIGHT(B1,2)+1,"00")))

If you have more than 100 consecutive occurrences, an If statement can
be incorporated to check the length of the cell above and proceed
accordingly.

Johnny wrote:
Hi,

the problem is need a formula or a macro for my excel 2003 work sheet.
this is part of my work sheet below:
column column
A B
-------------------------------
5 2

6 2

dog 1
dog 2
dog 1

that I want is, how to create a formula or macro to chane ( if column A is
dog, column B at the same row replace to T01 and by order(T02,T03) like
sample below

column column
A B
-------------------------------
9 2

10 2

dog T01
dog T02
dog T03

Regards
Johnny.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default formula or macro.


Sub CountDogs()

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

DogCount = 1
For RowCount = 1 To LastRow
If Cells(RowCount, "A") = "dog" Then
Cells(RowCount, "B") = "T" & Format(DogCount, "0#")
DogCount = DogCount + 1
End If
Next RowCount
End Sub
"JW" wrote:

Assuming you don't have more than 100 consecutive occurrences of a
given item, the formula below will work.
=IF(ISBLANK(A2),"",IF(A2<A1,"T01","T" & TEXT(RIGHT(B1,2)+1,"00")))

If you have more than 100 consecutive occurrences, an If statement can
be incorporated to check the length of the cell above and proceed
accordingly.

Johnny wrote:
Hi,

the problem is need a formula or a macro for my excel 2003 work sheet.
this is part of my work sheet below:
column column
A B
-------------------------------
5 2

6 2

dog 1
dog 2
dog 1

that I want is, how to create a formula or macro to chane ( if column A is
dog, column B at the same row replace to T01 and by order(T02,T03) like
sample below

column column
A B
-------------------------------
9 2

10 2

dog T01
dog T02
dog T03

Regards
Johnny.



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 126
Default formula or macro.

Guys

the macro is working great. thank you.

regards
Johnny.

"Joel" wrote:


Sub CountDogs()

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

DogCount = 1
For RowCount = 1 To LastRow
If Cells(RowCount, "A") = "dog" Then
Cells(RowCount, "B") = "T" & Format(DogCount, "0#")
DogCount = DogCount + 1
End If
Next RowCount
End Sub
"JW" wrote:

Assuming you don't have more than 100 consecutive occurrences of a
given item, the formula below will work.
=IF(ISBLANK(A2),"",IF(A2<A1,"T01","T" & TEXT(RIGHT(B1,2)+1,"00")))

If you have more than 100 consecutive occurrences, an If statement can
be incorporated to check the length of the cell above and proceed
accordingly.

Johnny wrote:
Hi,

the problem is need a formula or a macro for my excel 2003 work sheet.
this is part of my work sheet below:
column column
A B
-------------------------------
5 2

6 2

dog 1
dog 2
dog 1

that I want is, how to create a formula or macro to chane ( if column A is
dog, column B at the same row replace to T01 and by order(T02,T03) like
sample below

column column
A B
-------------------------------
9 2

10 2

dog T01
dog T02
dog T03

Regards
Johnny.



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
set formula by Macro [email protected] Excel Worksheet Functions 3 December 1st 06 02:02 PM
Macro Formula for Max value Gary''s Student Excel Worksheet Functions 0 November 30th 06 05:20 PM
Help with macro or formula JAZZNAURA Excel Discussion (Misc queries) 0 August 18th 06 08:41 AM
formula to a macro help PLEASE Hemming Excel Discussion (Misc queries) 2 March 9th 06 03:16 PM
Help on Macro or Formula Nigel Excel Discussion (Misc queries) 2 June 13th 05 01:27 PM


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