Closed Thread
Results 1 to 13 of 13

Duplicate Declaration error

  1. #1
    Registered User
    Join Date
    05-31-2007
    Posts
    49

    Duplicate Declaration error

    Hi

    I am getting "Duplicate Declaration" error while running my code. Cant post entire code as its too long but i am pasting the problem line.

    Can you please help me?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This is because a variable is declared twice within the same procedure.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    05-31-2007
    Posts
    49
    [QUOTE=royUK;2000513]This is because a variable is declared twice within the same procedure.[/QUOTE

    Yes i know that. But what is the solution. i thought filter(1) and filter(2) are different variables.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This is because a variable is declared twice in the same procedure. I also think the way you have declared the variables fc(1), etc Excel is expecting an array because only the last one is recognised as a string.

    You need to declare them like this
    Please Login or Register  to view this content.
    For an alternative way of doing multiple autofilters take a look here

  5. #5
    Registered User
    Join Date
    05-31-2007
    Posts
    49
    Quote Originally Posted by royUK View Post
    This is because a variable is declared twice in the same procedure. I also think the way you have declared the variables fc(1), etc Excel is expecting an array because only the last one is recognised as a string.

    You need to declare them like this
    Please Login or Register  to view this content.
    ]

    Declaring them like you suggested also give the same error. Any other ideas?

    Thanks
    j

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Can you attach the workbook?

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,461
    You dimension the array by specifying the bounds.

    So rather than 8 mentions use

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  8. #8
    Registered User
    Join Date
    05-31-2007
    Posts
    49
    Quote Originally Posted by royUK View Post
    Can you attach the workbook?
    Here we go...
    Attached Files Attached Files

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your data in the sheet does not have a header row, so it won't autofilter correctly anyway.

  10. #10
    Registered User
    Join Date
    05-31-2007
    Posts
    49
    Quote Originally Posted by royUK View Post
    Your data in the sheet does not have a header row, so it won't autofilter correctly anyway.
    Well as i mentioned earlier this is not original code and original workbook and so there may be little things like that. but the problem is with the error which is correctly reproduced in my sample file.

    The header row does not have anything to do with the duplication error. Even after putting a header row it gives the same error.

    Do you have any other ideas?

    Thanks a lot
    J

  11. #11
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    xyz123,

    Please read forum rules below and then add the link to the other excel forum as cross posting without the link is not permitted

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello xyz123,

    Andy was correct about you needing to create an Array. Unfortunately, that was only the beginning. You had several other errors as well. I have corrected your macro and added it to the attached workbook. Here is the corrected macro code...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files

  13. #13
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Thread closed for not following my request

    PM me if you agree to the rules

    VBA Noob

Closed Thread

Thread Information

Users Browsing this Thread

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

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