Results 1 to 8 of 8

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

Threaded View

  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.
    For Each Cell in DstRng
    Sub WEEKLY_WFMPortfolio_CopyFormula()
    '
    ' WEEKLY_WFMPortfolio_CopyFormula Macro
    '
    
    '
      Dim Cell As Range
      Dim DstCell As Range
      Dim RngEnd As Range
      Dim SrcRng As Range
      
        Set DstRng = Range("H11:T11")
        Set SrcRng = Range("AI11:AI36")
        Set RngEnd = Cells(Rows.Count, SrcRng.Column).End(xlUp)
        Set SrcRng = IIf(RngEnd.Row < SrcRng.Row, SrcRng, Range(SrcRng, RngEnd))
    
          For Each Cell In DstRng
            If WorksheetFunction.CountA(Cell.Resize(SrcRng.Rows.Count, 1)) = 0 Then
               Cell.Resize(SrcRng.Rows.Count, 1).Value = SrcRng.Value
               Exit For
            End If
          Next Cell
        Range("AC11:AC36").Select
        Application.CutCopyMode = False
        Selection.Copy
        Range("AH11").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveWindow.LargeScroll ToRight:=-1
        Range("B3").Select
        
    End Sub
    Attached Files Attached Files
    Last edited by Cascus; 10-06-2011 at 04:41 PM. Reason: closed ticket

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