Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Put numbers in column B cells when Value Change in Column A cells

Hi all, I have data in column A (see below)

ROW A---------Column
1 Heading
2 BTC
3 BTC
4 BTC
5 GIS
6 GIS
7 VXZ
8 VXZ
9 BTC
10 BTC

I want macro on button which should produce result in column B
something like (see below)

ROW A B---------Columns
1 Heading Heading
2 BTC 1
3 BTC 1
4 BTC 1
5 GIS 2
6 GIS 2
7 VXZ 3
8 VXZ 3
9 BTC 4
10 BTC 4

In other words I want macro to check in column A cells and put numbers
in column B cells and when where value become different in column A
cells then it should also change the value in column B cells. Please
can any friend can help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Put numbers in column B cells when Value Change in Column A cells

Hi,

You don't need a macro for this you can use this in B2 dragged down

=IF(A2=A1,MAX($B$1:B1,1),MAX($B$1:B1)+1)

but if that's what you want then right click your sheet tab, view code and
paste this in and run it.

Sub marine()
Dim num As Long
Dim Myrange As Range
num = 1
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set Myrange = Range("A3:A" & lastrow)
Range("B2").Value = num
For Each c In Myrange
If c.Value = c.Offset(-1).Value Then
c.Offset(, 1).Value = num
Else
num = num + 1
c.Offset(, 1).Value = num
End If
Next
End Sub


"K" wrote:

Hi all, I have data in column A (see below)

ROW A---------Column
1 Heading
2 BTC
3 BTC
4 BTC
5 GIS
6 GIS
7 VXZ
8 VXZ
9 BTC
10 BTC

I want macro on button which should produce result in column B
something like (see below)

ROW A B---------Columns
1 Heading Heading
2 BTC 1
3 BTC 1
4 BTC 1
5 GIS 2
6 GIS 2
7 VXZ 3
8 VXZ 3
9 BTC 4
10 BTC 4

In other words I want macro to check in column A cells and put numbers
in column B cells and when where value become different in column A
cells then it should also change the value in column B cells. Please
can any friend can help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Put numbers in column B cells when Value Change in Column A cells

Hi

Another formula for B2 is
=IF(A2="","",SUM(B1,--(A2<A1)))
(Copy formula down - and you can have pre-prepared cells with formula there
too)

Arvi Laanemets


"K" wrote in message
...
Hi all, I have data in column A (see below)

ROW A---------Column
1 Heading
2 BTC
3 BTC
4 BTC
5 GIS
6 GIS
7 VXZ
8 VXZ
9 BTC
10 BTC

I want macro on button which should produce result in column B
something like (see below)

ROW A B---------Columns
1 Heading Heading
2 BTC 1
3 BTC 1
4 BTC 1
5 GIS 2
6 GIS 2
7 VXZ 3
8 VXZ 3
9 BTC 4
10 BTC 4

In other words I want macro to check in column A cells and put numbers
in column B cells and when where value become different in column A
cells then it should also change the value in column B cells. Please
can any friend can help.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Put numbers in column B cells when Value Change in Column A cells

On Nov 14, 12:53*pm, "Arvi Laanemets" wrote:
Hi

Another formula for B2 is
=IF(A2="","",SUM(B1,--(A2<A1)))
(Copy formula down - and you can have pre-prepared cells with formula there
too)

Arvi Laanemets

"K" wrote in message

...



Hi all, *I have data in column A (see below)


ROW * * * * * *A---------Column
1 * * * * * * *Heading
2 * * * * * * *BTC
3 * * * * * * *BTC
4 * * * * * * *BTC
5 * * * * * * *GIS
6 * * * * * * *GIS
7 * * * * * * *VXZ
8 * * * * * * *VXZ
9 * * * * * * *BTC
10 * * * * * *BTC


I want macro on button which should produce result in column B
something like (see below)


ROW * * * * * *A * * * * * * * * B---------Columns
1 * * * * * * *Heading * Heading
2 * * * * * * *BTC * * * * * * * * 1
3 * * * * * * *BTC * * * * * * * * 1
4 * * * * * * *BTC * * * * * * * * 1
5 * * * * * * *GIS * * * * * * * * *2
6 * * * * * * *GIS * * * * * * * * *2
7 * * * * * * *VXZ * * * * * * * * *3
8 * * * * * * *VXZ * * * * * * * * *3
9 * * * * * * *BTC * * * * * * * * 4
10 * * * * * *BTC * * * * * * * * 4


In other words I want macro to check in column A cells and put numbers
in column B cells and when where value become different in column A
cells then it should also change the value in column B cells. *Please
can any friend can help.- Hide quoted text -


- Show quoted text -


thanks guys
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
To get an average of a column of numbers not zero/blank cells Neil Excel Worksheet Functions 4 June 22nd 08 02:57 PM
Display cells(text) in one column based on cells which are present inother column [email protected] Excel Discussion (Misc queries) 1 May 12th 08 01:40 PM
Copying a column of single cells into a column of merged cells [email protected] Excel Discussion (Misc queries) 1 August 16th 06 01:18 PM
How can I change column numbers back to column letters? Space Elf Excel Worksheet Functions 3 March 2nd 06 09:35 PM
How do I identify cells with matching numbers within a column. dbmeyer Excel Worksheet Functions 6 February 26th 06 10:33 PM


All times are GMT +1. The time now is 07:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"