Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 122
Default Getting macro to run with pasted function

Greetings,

I am trying to remove all duplicate rows by checking the first five colums
in each row. The spreadsheet is 20 colums by 800 rows, and I am using Excel
2003.

I have tried to get Chip Pearson's DeleteDuplicatesViaFilter to run, and I'm
not having any luck. Don't have much, (if any) experience with Visual Basic.
I'm not sure where to put the range of cells I want checked. I also don't
know how to name the macro to be able to make it run. Is this the best
solution? Any help would be greatly appreciated.

Here is the first part of his code:

Function DeleteDuplicatesViaFilter(ColumnRangeOfDuplicates As Range) As Long
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
' DeleteDuplicatesViaFilter
' This function uses Advanced Filter to remove duplicate records from
' the rows spanned by ColumnRangeOfDuplicates. A row is considered to
' be a duplicate of another row if the columns spanned by
ColumnRangeOfDuplictes
' are equal. Columns outside of those spanned by ColumnRangeOfDuplicates
' are not tested. The function returns the number of rows deleted, including
' 0 if there were no duplicates, or -1 if an error occurred, such as a
' protected sheet or a ColumnRangeOfDuplicates range with multiple areas.
' Note that Advanced Filter considers the first row to be the header row
' of the data, so it will never be deleted.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

Dim DeleteRange As Range
Dim Rng As Range
Dim SaveCalc As Long
Dim SaveEvents As Long
Dim SaveUpdating As Long
Dim BeginRowCount As Long
Dim EndRowCount As Long

--
Thanks, Glenn
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 5,441
Default Getting macro to run with pasted function

Glenn,

You need to call the function from a subroutine. The example below works to
eliminate duplicates based on values in the first 5 columns, and assumes
that you have labels in row 1, and no gaps in your data set:

Sub TestForGlenn()
MsgBox "The function deleted " & _
DeleteDuplicatesViaFilter( _
Intersect(Range("A:E"), Range("A1").CurrentRegion)) & _
" records."
End Sub

Function DeleteDuplicatesViaFilter(ColumnRangeOfDuplicates As Range) As Long
'rest of function code here....


Simply run the macro 'TestForGlenn'

HTH,
Bernie
MS Excel MVP


"Glenn" wrote in message
...
Greetings,

I am trying to remove all duplicate rows by checking the first five colums
in each row. The spreadsheet is 20 colums by 800 rows, and I am using
Excel
2003.

I have tried to get Chip Pearson's DeleteDuplicatesViaFilter to run, and
I'm
not having any luck. Don't have much, (if any) experience with Visual
Basic.
I'm not sure where to put the range of cells I want checked. I also don't
know how to name the macro to be able to make it run. Is this the best
solution? Any help would be greatly appreciated.

Here is the first part of his code:

Function DeleteDuplicatesViaFilter(ColumnRangeOfDuplicates As Range) As
Long
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
' DeleteDuplicatesViaFilter
' This function uses Advanced Filter to remove duplicate records from
' the rows spanned by ColumnRangeOfDuplicates. A row is considered to
' be a duplicate of another row if the columns spanned by
ColumnRangeOfDuplictes
' are equal. Columns outside of those spanned by ColumnRangeOfDuplicates
' are not tested. The function returns the number of rows deleted,
including
' 0 if there were no duplicates, or -1 if an error occurred, such as a
' protected sheet or a ColumnRangeOfDuplicates range with multiple areas.
' Note that Advanced Filter considers the first row to be the header row
' of the data, so it will never be deleted.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

Dim DeleteRange As Range
Dim Rng As Range
Dim SaveCalc As Long
Dim SaveEvents As Long
Dim SaveUpdating As Long
Dim BeginRowCount As Long
Dim EndRowCount As Long

--
Thanks, Glenn



  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 122
Default Getting macro to run with pasted function

Bernie,

Thank you so much, that did the trick.
--
Glenn


"Bernie Deitrick" wrote:

Glenn,

You need to call the function from a subroutine. The example below works to
eliminate duplicates based on values in the first 5 columns, and assumes
that you have labels in row 1, and no gaps in your data set:

Sub TestForGlenn()
MsgBox "The function deleted " & _
DeleteDuplicatesViaFilter( _
Intersect(Range("A:E"), Range("A1").CurrentRegion)) & _
" records."
End Sub

Function DeleteDuplicatesViaFilter(ColumnRangeOfDuplicates As Range) As Long
'rest of function code here....


Simply run the macro 'TestForGlenn'

HTH,
Bernie
MS Excel MVP


"Glenn" wrote in message
...
Greetings,

I am trying to remove all duplicate rows by checking the first five colums
in each row. The spreadsheet is 20 colums by 800 rows, and I am using
Excel
2003.

I have tried to get Chip Pearson's DeleteDuplicatesViaFilter to run, and
I'm
not having any luck. Don't have much, (if any) experience with Visual
Basic.
I'm not sure where to put the range of cells I want checked. I also don't
know how to name the macro to be able to make it run. Is this the best
solution? Any help would be greatly appreciated.

Here is the first part of his code:

Function DeleteDuplicatesViaFilter(ColumnRangeOfDuplicates As Range) As
Long
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
' DeleteDuplicatesViaFilter
' This function uses Advanced Filter to remove duplicate records from
' the rows spanned by ColumnRangeOfDuplicates. A row is considered to
' be a duplicate of another row if the columns spanned by
ColumnRangeOfDuplictes
' are equal. Columns outside of those spanned by ColumnRangeOfDuplicates
' are not tested. The function returns the number of rows deleted,
including
' 0 if there were no duplicates, or -1 if an error occurred, such as a
' protected sheet or a ColumnRangeOfDuplicates range with multiple areas.
' Note that Advanced Filter considers the first row to be the header row
' of the data, so it will never be deleted.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

Dim DeleteRange As Range
Dim Rng As Range
Dim SaveCalc As Long
Dim SaveEvents As Long
Dim SaveUpdating As Long
Dim BeginRowCount As Long
Dim EndRowCount As Long

--
Thanks, Glenn




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
pasted function tng Excel Discussion (Misc queries) 5 February 18th 06 06:36 PM
right function on pasted link Bob Excel Worksheet Functions 1 November 4th 05 09:58 PM
Pasted text is broken up Sloth Excel Discussion (Misc queries) 1 September 14th 05 01:04 AM
How do I get a pasted screen print to appear? Fecha1776 Excel Discussion (Misc queries) 0 July 26th 05 05:31 PM
Can something be cut and then pasted into a comment? Dave Excel Discussion (Misc queries) 1 April 15th 05 07:01 PM


All times are GMT +1. The time now is 07:01 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"