+ Reply to Thread
Results 1 to 3 of 3

Sub procedures stop working when combined.

  1. #1
    Registered User
    Join Date
    01-12-2011
    Location
    Queens, NY
    MS-Off Ver
    Excel 2007
    Posts
    7

    Sub procedures stop working when combined.

    I've been working on a piece of test code that opens another spread sheet, copies all the information in a particular column, then pastes that data back in the original spread sheet. To come up with this I wrote two separate sub procedures: Copy_Cells which opens the file, closes it and pastes the data, and Select_Rows which selects the right cells in the opened file and copies them. I wrote these two pieces individually and tested them till I got them to work exactly as needed, however when I tried to merge them together as seen in the following piece of code, Copy_Cells only selects the first cell with information in it and no more. I imagine that the cause of this error is some inherent function of my code that I'm simply not aware of, so any help in correcting this problem would be greatly appreciated.

    P.S. The code is now starting from cell A2 and counting up, when the point of the code is to start at A2 and count down. The code is on sheet 1 Open Test. For a test document I wrote a word in A1, then numbers for the rest of the column for some arbitrary range.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Sub procedures stop working when combined.

    Macros shouldn't go into the Sheet module unless there is a specific sheet-event level that needs to be managed. These are normal macros and go into regular code modules. (Insert > Module to get Module1 to appear).

    This is how I would write that:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Sub procedures stop working when combined.

    Alternative:
    Please Login or Register  to view this content.



+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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