+ Reply to Thread
Results 1 to 8 of 8

calling Subroutine is not working properly

  1. #1
    Registered User
    Join Date
    10-30-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    92

    calling Subroutine is not working properly

    i have wrriten a macro for calling a subroutine.

    eg:
    Please Login or Register  to view this content.
    when i call Perilthree_CountOSUS subroutine from different location or another subroutine i am getting result as zero in h18 location where as when i run the subroutine individually i got the correct result.

    can anybody let me know where the problem is...
    i was really doesn't know why it is producing different results when calling differently..


    Its very urgent....
    Last edited by arlu1201; 11-04-2012 at 10:02 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: calling Subroutine is not working properly

    One possibility is if OSUS Extract is filtered for something else in a different column, that filter is not cleared before filtering column F =3

    Maybe try something like this to clear any previous filters.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-30-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    92

    Re: calling Subroutine is not working properly

    Thanks a lot dude.. its working great...
    i have a another question

    when i tried to run this code i should get the unique values count but i am getting count of duplicates +1, here i already put
    Sheets("Output sheet").Range("h18").Value = UniqueValues.Count - 1
    for decreasing the count by 1 for spaces
    why i am getting another count as an extra. what it is considering in its count other than the spaces.
    Quote Originally Posted by AlphaFrog View Post
    One possibility is if OSUS Extract is filtered for something else in a different column, that filter is not cleared before filtering column F =3

    Maybe try something like this to clear any previous filters.

    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: calling Subroutine is not working properly

    Hard to say without seeing or knowing the nature of your data.

    What is in column J?
    Is the data derived from formulas or are they constants?

  5. #5
    Registered User
    Join Date
    10-30-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    92

    Re: calling Subroutine is not working properly

    in J column i have numbers which are manually entered and they looks like
    27411221
    27411221
    27416404
    27416404
    27416405
    27416405
    27416471

    these are not derived from any formulas

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: calling Subroutine is not working properly

    If a value in column J has a trailing space, it will not be considered the same as one without; e.g
    "27416471" <> "27416471 "

    Maybe try trimming the values (this is a total guess)
    UniqueValues.Add cl.Value, Trim(CStr(cl.Value)) ' add the unique item

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: calling Subroutine is not working properly

    Kiran527,

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  8. #8
    Registered User
    Join Date
    10-30-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    92

    Re: calling Subroutine is not working properly

    Hey Thats cool.... its working great...

    Thanks a lot dude........

    Quote Originally Posted by AlphaFrog View Post
    If a value in column J has a trailing space, it will not be considered the same as one without; e.g
    "27416471" <> "27416471 "

    Maybe try trimming the values (this is a total guess)
    UniqueValues.Add cl.Value, Trim(CStr(cl.Value)) ' add the unique item

+ Reply to 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