+ Reply to Thread
Results 1 to 6 of 6

Returning the number of cells from one method to another method.

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Thumbs up Returning the number of cells from one method to another method.

    Hi all,
    First I am going to give you some code, and then describe what I am attempting to do.

    Please Login or Register  to view this content.
    If the value is found, this method is run from within "findCansim" to find the values and then copy them.

    Please Login or Register  to view this content.
    Somehow, I need the RngCount value to return to the first method so that it looks something like this(the edits are underlined):

    Please Login or Register  to view this content.
    The end result is to paste the values into our workbook from the found values in the source workbook. The starting cell to paste from is dependant on the number of cells being pasted. I hope this makes sense. If an example book is needed then let me know and I'll have to make one because the files are too large to upload in their current conditions.
    Last edited by Mordred; 09-08-2010 at 11:29 AM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Returning the number of cells from one method to another method.

    Convert findCansim into a function that returns the relevant value. Either that or pass a variable ByRef to the FindCansim sub so that it can alter it for later use.
    Note - this:
    Please Login or Register  to view this content.
    should be:
    Please Login or Register  to view this content.
    without parentheses.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Returning the number of cells from one method to another method.

    Thanks romperstomper, I'll try as you suggested. If I pass a variable ByRef to the findCansim method, should it then look like this (given it already has a ByVal being passed to it):

    Please Login or Register  to view this content.
    I've never had to pass more than one argument until your suggestion so I am a little unclear.

    Edit: And if I do it like this, don't I have to also pass CName again?

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Returning the number of cells from one method to another method.

    Yes that's correct. Calling it would be like so:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Returning the number of cells from one method to another method.

    I'll change up some of my code to try and make this work. I'll let you know how it goes either within the next half hour (if it works for me) or sometime in the next few hours (when I am home from work). Thanks again.

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Thumbs up Re: Returning the number of cells from one method to another method.

    After trying to figure this out by passing more than one argument through one method, I thought to myself: 'Why not just do this all in one method?' This code is probably a little crude but it only takes 13 seconds to find, copy, and paste the required data from 144 sheets.

    Please Login or Register  to view this content.
    I'm completely open to suggestions on improving this though but it seems to be fine.

+ 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