ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help autofilter (https://www.excelbanter.com/excel-programming/389596-help-autofilter.html)

[email protected]

Help autofilter
 
I am a new VBer

I am sent data every month of varying record numbers. It is invoice
details, so some rows repeat data, like name etc.

I am trying to write a macro which will streamline the data into the
format which I require.

The procedure is:

1.Start at A:3

2. Check the cell A:2 above for the same reference no or
Check if it is same reference number as the in the cell below it

3. If it is then it it will copy and paste column contents of A:3 into
a new sheet.


4. Loop until gets to end of records

Any help would be greatly appreciated

Mazziah


merjet

Help autofilter
 
Sub ListDups()
Dim c As Range
Dim rng As Range
Dim rng2 As Range
Dim iRow As Long
Dim iEnd As Long
iEnd = Sheets("Sheet1").Range("A2").End(xlDown).Row
Set rng = Sheets("Sheet1").Range("A2:A" & iEnd)
iRow = 1
For Each c In rng
If Application.CountIf(rng, c) 1 Then
Set rng2 = Sheets("Sheet2").Range("A1:A" & iRow)
If IsError(Application.Match(c, rng2, 0)) Then
iRow = iRow + 1
Sheets("Sheet2").Cells(iRow, "A") = c
End If
End If
Next c
End Sub

Hth,
Merjet




All times are GMT +1. The time now is 04:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com