Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 18th, 2009, 01:06 AM
Authorized User
 
Join Date: Mar 2008
Posts: 74
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via ICQ to sektor
Default RemoveDuplicates method doesn't work in Worksheet module [Excel 2010]

I have a simple task - delete duplicates from range. Here's code:

Code:
Dim rng As Range
Set rng = Range("A1").CurrentRegion
rng.RemoveDuplicates Columns:=Array(1, 2), Header:=xlNo

However, this code doesn't work in worksheet module, but it works in STANDARD module (of course with sheet prefixing)!!! Is there any explanation of such Excel's VBA behavior?
 
Old September 18th, 2009, 09:43 AM
JP JP is offline
Authorized User
 
Join Date: Apr 2008
Posts: 57
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Is the code inside an event handler?

Note that according to MS online help, you can't remove duplicate values from data that is outlined or that has subtotals.

--JP

Quote:
Originally Posted by sektor View Post
I have a simple task - delete duplicates from range. Here's code:

Code:
Dim rng As Range
Set rng = Range("A1").CurrentRegion
rng.RemoveDuplicates Columns:=Array(1, 2), Header:=xlNo

However, this code doesn't work in worksheet module, but it works in STANDARD module (of course with sheet prefixing)!!! Is there any explanation of such Excel's VBA behavior?
 
Old September 21st, 2009, 12:10 AM
Authorized User
 
Join Date: Mar 2008
Posts: 74
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via ICQ to sektor
Default

No, code ain't in event handler, but in the worksheet module. I just make call from event handler. And my data isn't outlined and doesn't have subtotals.

The thing is that I just re-work code. In previous code I have event handler, which calls, say, Sub1. This Sub1, in its turn, calls Sub2 etc.
Thus, in my event handler I have only one line: Call Sub1. I tried to do the same thing in new workbook. All works fine. :(

Last edited by sektor; September 21st, 2009 at 12:14 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Reflecting changes in Excel Worksheet...???? hunk1985 General .NET 0 September 12th, 2007 06:29 AM
How to continue to next new excel worksheet christine_wmw Classic ASP Basics 0 January 24th, 2007 02:54 AM
DYNAMIC EXCEL WORKSHEET NAME?? tbaquero Classic ASP Professional 2 October 5th, 2004 08:30 AM
VB module fails to work when data > 170,000 tuples andy_routledge Access VBA 2 August 6th, 2003 06:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.