Iinsert value into column L ...

S

sal21

If is possible with a mcro...

my problem, i have this sheet with many value into column A (all value
are already oredered) is possible to insert into column L the count
numebr of value repeated from a equal range block?
Example:
into line 3 and 4 is present the same value 4500450961 well inert into
column L the numer 2 into L3, blank the other line refered line 4

into line 11, 12 and 13 is present the same value 4500451080 well inert
into column L the numer 3 into L11, blank the other line refered line 12
and 13

if the value into acolumn A is present only one insert into column L
the value "0"

Tks.


+-------------------------------------------------------------------+
|Filename: ADD_NUMBER.zip |
|Download: http://www.excelforum.com/attachment.php?postid=3786 |
+-------------------------------------------------------------------+
 
R

Rowan

This is a bit ugly and assumes your data starts in row 2 i.e headings in
first row:

Sub huh()
Dim eRow As Long
Dim ColA As Range
Dim cell As Range
Dim cNtr As Long
Dim cRow As Long
Dim val As Variant '<change to suit data in column A

eRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Set ColA = Range(Cells(3, 1), Cells(eRow, 1))
val = Cells(2, 1).Value
cRow = 2
cNtr = 1
For Each cell In ColA
If cell.Value = val Then
cNtr = cNtr + 1
Else
If cNtr = 1 Then
Cells(cRow, 12).Value = 0
Else
Cells(cRow, 12).Value = cNtr
End If
cRow = cell.Row
cNtr = 1
val = cell.Value
End If
Next cell
End Sub

Hope this helps
Rowan
 
S

sal21

Rowan said:
This is a bit ugly and assumes your data starts in row 2 i.e headings
in
first row:

Sub huh()
Dim eRow As Long
Dim ColA As Range
Dim cell As Range
Dim cNtr As Long
Dim cRow As Long
Dim val As Variant '<change to suit data in column A

eRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Set ColA = Range(Cells(3, 1), Cells(eRow, 1))
val = Cells(2, 1).Value
cRow = 2
cNtr = 1
For Each cell In ColA
If cell.Value = val Then
cNtr = cNtr + 1
Else
If cNtr = 1 Then
Cells(cRow, 12).Value = 0
Else
Cells(cRow, 12).Value = cNtr
End If
cRow = cell.Row
cNtr = 1
val = cell.Value
End If
Next cell
End Sub

Hope this helps
Rowan

Work fine!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top