Технолог
Сообщения: 819
Благодарности: 117
|
Профиль
|
Отправить PM
| Цитировать
Подразумеваем что левый верхний угол исходной таблицы находится в ячейке А1.
Тогда вешай на любую кнопку нижеследующий макрос и наслаждайся результатом.
Если в другой ячейке - придется малость подкорректировать.
Текст макроса (скопировать в стандартный модуль):
Sub Duplicate_delete()
NN = InputBox("Enter column number") 'Здесь вводи номер столбца по которому сравниваются значения
N = CInt(NN)
ColumnsCount = Cells(1, 1).End(xlToRight).Column
RowsCount = Cells(1, 1).End(xlDown).Row
Cells(1, ColumnsCount + 1).Value = 1
Cells(1, ColumnsCount + 1).AutoFill Destination:=Range(Cells(1, ColumnsCount + 1), _
Cells(RowsCount, ColumnsCount + 1)), Type:=xlFillSeries
Range(Cells(1, 1), Cells(RowsCount, ColumnsCount + 1)).Sort Key1:=Cells(1, N), Order1:=xlAscending
RowStart = 2
1
For iCount = RowStart To Cells(1, N).End(xlDown).Row
If Cells(iCount, N).Value = Cells(iCount - 1, N).Value Then
Rows(iCount).Delete shift:=xlUp
If iCount > 3 Then RowStart = iCount - 1
Exit For
End If
Next iCount
If RowStart < Cells(1, N).End(xlDown).Row Then GoTo 1
Range(Cells(1, 1), Cells(Cells(1, N).End(xlDown).Row, ColumnsCount + 1)).Sort _
Key1:=Columns(ColumnsCount + 1), Order1:=xlAscending
Columns(ColumnsCount + 1).Delete shift:=xlLeft
End Sub
|