+ Reply to Thread
Results 1 to 8 of 8

Macro broken - copy data range column to empty data range column

  1. #1
    Registered User
    Join Date
    09-15-2008
    Location
    Vancouver, Washington
    MS-Off Ver
    2007
    Posts
    11

    Unhappy Macro broken - copy data range column to empty data range column

    Hi all,
    I have this macro that has been working great for many moons but recently died. Here is what it does:
    • Copy range of data (single column AI11:AI36)
    • Cycle through a range of columns to find the first available blank range (Multiple columns H11:T36) that is empty and pastes values of copy.
    • Copy range AC11:AC36 and paste values in AI11:AI36.

    About a month ago it just stopped working. I can't tell you why, nothing in the code or spreadsheet has changed. There are no errors. The code runs, but no data is copied over to the blank cells. However, it does perform the last step which is to copy the data from AC11:AC36 and paste values in AI11:AI36. So I am sure it is something in the For Each iteration.

    The code is below. It is an old macro, something that was done for me on this forum over a year ago.

    I have attached a spreadsheet, it is close to the original as I can get without violating company privacy policy, and I need this to cycle through multiple sheets, which I am sure I can do on my own. My big thing is I can't seem to debug why the function it is not working.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Cascus; 10-06-2011 at 04:41 PM. Reason: closed ticket

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Macro broken - copy data range column to empty data range column

    Look at your SUPPOSED empty cells in columns H to T.
    I don't know what is their content but there is something there.
    Create a COUNTA function in row 10 of those columns and you'll see it is not 0.
    This prevent your condition in the FOR Each Cell loop to be TRUE and copy the range.
    You'll have to delete all those cells for your macro to work properly.

  3. #3
    Registered User
    Join Date
    09-15-2008
    Location
    Vancouver, Washington
    MS-Off Ver
    2007
    Posts
    11

    Re: Macro broken - copy data range column to empty data range column

    My understanding, from when it was first built, is that this loop looks at each column in H11:T11 to find the first empty cell in the column starting at H11 and going down to .end. I just opened the file, put a COUNTA function in row 10 counting rows 11:36 and come up with 0. Yes, there are columns with data in there, but I want the macro to find the first column with no data, and paste the data from AI11:AI36 into that empty column. Does that make sense?

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Macro broken - copy data range column to empty data range column

    I just tested your macro and it is working on my Excel 2010.
    In your workbook, first empty column is Q and the macro properly copies the values of AI11:AI36 to this place.
    Do you get the same results? Is it the same file that was there yesterday?
    I can't explain why but it seems to be working now. Doesn't it?

  5. #5
    Registered User
    Join Date
    09-15-2008
    Location
    Vancouver, Washington
    MS-Off Ver
    2007
    Posts
    11

    Re: Macro broken - copy data range column to empty data range column

    Yes, that file does run the code. Wierd. I can't explain that either. i will go back to my, non-stripped out version, and see what the difference is.....besides a TON of formulas removed. I will move to solved and post what I found, if anything.
    I Love Pizza

  6. #6
    Registered User
    Join Date
    09-15-2008
    Location
    Vancouver, Washington
    MS-Off Ver
    2007
    Posts
    11

    Re: Macro broken - copy data range column to empty data range column

    Still not working. I did a counta on columns H11:T11 and column T is now blank, as I manualy updated last time. The only part that worked was copying AC11:AC36 to AI11:AI36. Not sure why. No errors at all. I am having a hard time debugging as I didn't create this macro and don't understand exactly what this macro is doing, in laymens terms, for the loop. I "THINK" it is counting cells H11:T11 and attempting to find the number of columns over to count before dropping in the contents of AI11:AI36, but I don't show where it is actually copying the data from AI11:AI36.

  7. #7
    Registered User
    Join Date
    09-15-2008
    Location
    Vancouver, Washington
    MS-Off Ver
    2007
    Posts
    11

    Re: Macro broken - copy data range column to empty data range column

    Yet another update. It seems that the line which tried to judge how many rows to count, was coming up with some odd numbers. for example. The Rows.Count was pulling all rows in the worksheet in SrcRng.Column (which = 35 columns from left) and the final RngEnd number was 43.xxxxxxxxxx a lot of numbers. It should have only counted about 41 rows from the top and then do an .xlUp. So I hard coded it that way and now it is pulling normally.

    The Problem is that on row 43 - 101, in the original sheet not posted, has information in the cells in column 35. Originally I wanted the code to look at each cell of rows=36 starting at cell row 11 of columns H:T to only paste values data from AI11:AI36 into the column with a countA = to zero. This modified version should work though.

    Please Login or Register  to view this content.
    Original Code


    Please Login or Register  to view this content.
    Modified, slightly

  8. #8
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Macro broken - copy data range column to empty data range column

    Looks fine to me.

+ 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