You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

its in vba (excel)

Thanks

1

2

2

1

1

1

1

3

3

3

1

1

2

2

1

2

2

1

1

3

3

3

1

1

1

3

3

3

1

2

2

like this.. so i need x against the 'first' instance of 2 and 3. getting y against 1 is easy as there is only one instance but having problem with 2 and 3. rest of the instances will have a y.

eg,

A B

2 x

2 y

1 y

3 x

3 y

3 y

I think the e.g is like this

2 x

2 y

3 x

3 y

3 y

I pasted the data from post number 5 on a range of D10 : D40.

Then I wrote this formula in E10:

=IF(COUNTIF($D$10 : D10,D10)=1,"x","y")

Once you type the last bracket, press CONTROL+SHIFT+ENTER, and the formula will get {} around it.

Now double click down..>!

you can have x or y against 1, dosent matter, prob is with 2 and 3.

sorry i m n00b in vba.But

the logic will be like this

consider range of column A is A1:A20 => output will be B1:B20

start from A1 -> store it in a temp variable

Read A2 cell value & compare it with the temp variable if = then put y else put x

this will go on till A20

temp variable will always store the previous cell value

no its not working..

Yes, because you did not follow the way I asked you to.

sorry i m n00b in vba.But

the logic will be like this

consider range of column A is A1:A20 => output will be B1:B20

start from A1 -> store it in a temp variable

Read A2 cell value & compare it with the temp variable if = then put y else put x

this will go on till A20

temp variable will always store the previous cell value

There is absolutely no USE for VBA for this. VBA is used only when native excel cannot do the job.

Please see the sheet I have attached. Look at the yellow cells, and understand the formula I wrote. It is an array function, and does the job perfect.

Sample.xls - 4shared.com - online file sharing and storage - download

And I repeat again, there is no need to do this with VBA. It is shooting a fly with a cannon. Unless your data is crossing 50,000 rows or something.