+ Reply to Thread
Results 1 to 4 of 4

Variable array argument

  1. #1
    Registered User
    Join Date
    08-16-2013
    Location
    Omaha
    MS-Off Ver
    Excel 2007
    Posts
    10

    Variable array argument

    I am writing VBA code that includes the removal of duplicate records. Using Developer, I determined that the instruction for removing duplicated records from the original data set that has 1211 records, starting at A1, aand which can reach column Y, are:

    Columns("A:Y").Select
    ActiveSheet.Range("$A$1:$Y$1211").RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25), Header:=xlNo

    It is quite possible that in other data sets, the last column may go beyond column Y, i.e., beyond the 25th column. It is easy to vary the range "$A$1:$Y$1211" to what's appropriate, but how do I make the Array(1,...,25) dynamic?

    Can anybody help?

  2. #2
    Registered User
    Join Date
    11-13-2006
    Posts
    87

    Re: Variable array argument

    Try this, it's not tested, but should give you some ideas even if it doesn't quite work.

    Please Login or Register  to view this content.

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Variable array argument

    you can create an array but you have to use CVar when you pass it as the argument
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Registered User
    Join Date
    08-16-2013
    Location
    Omaha
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Variable array argument

    Quote Originally Posted by JosephP View Post
    you can create an array but you have to use CVar when you pass it as the argument
    Please Login or Register  to view this content.
    That's it! I was missing the CVar()!

    Thank you!!!!!!!!!!!!!!!!!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Can I have a Variable Argument List?
    By XmisterIS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2014, 08:02 AM
  2. SEARCH function returns array if first argument is array--Huh?
    By 6StringJazzer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-10-2012, 07:23 PM
  3. [SOLVED] ByRef argument type mismatch / Passing array as a function argument
    By pzling in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-29-2012, 06:23 PM
  4. Function (array argument, range argument, string argument) vba
    By Witek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-24-2005, 11:07 AM
  5. Variable as argument in filter range
    By Bert in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2005, 07:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1