Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 18th, 2009, 01:06 AM
Authorized User
 
Join Date: Mar 2008
Location: , , Russia.
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?
Reply With Quote
  #2 (permalink)  
Old September 18th, 2009, 09:43 AM
JP JP is offline
Authorized User
Points: 199, Level: 3
Points: 199, Level: 3 Points: 199, Level: 3 Points: 199, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2008
Location: NYC, NY, USA.
Posts: 57
Thanks: 1
Thanked 2 Times in 2 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?
Reply With Quote
  #3 (permalink)  
Old September 21st, 2009, 12:10 AM
Authorized User
 
Join Date: Mar 2008
Location: , , Russia.
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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 01: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



All times are GMT -4. The time now is 12:01 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.