How to modify existing VBA to move rows from one sheet to another

ksantos16

New Member
Joined
Jan 28, 2016
Messages
3
I inherited a workbook that has a VBA code to move items that are marked "Closed" in column D to another worksheet that has been pre-prepared. The request is to use this workbook for another, similar purpose. I had to add a column, which didn't seem to affect things so long as I made that same change to the new worksheet.

My two major issues are:

1) The new data will have many more rows of information than the original form and when I add rows, they do not seem to be recognized and are not moved when the command button is clicked.
2) The code as written doesn't transfer information from column A to the new worksheet.

When I click the command button to move the information, I receive this error: "Run-time error '1004': To do this, all the merged cells need to the be the same size." And it gives me the option to "End", "Debug" or "Help". The "Continue" button is greyed out. When I click any of them, it will still move some of the rows the information to the new sheet.

I have attempted to make all the cells the same size and still get this error, so I don't know if there is something else that I'm missing.

The VBA code as currently written is as follows:
Code:
Sub move_closed()

Dim Status, Rng As Range
Application.ScreenUpdating = False

begin:
Set Rng = Sheets("Open").Range("D8:D57") 'sets the range to use
    For Each ItemStatus In Rng
    
    If ItemStatus = "" Then GoTo jmp
    
    If ItemStatus = "Closed" Then
        current_row = ItemStatus.Row
        closed_row = "B" & current_row & ":AK" & current_row
        Range(closed_row).Select
        Selection.Copy
        Sheets("Closed").Select
    
        Range("B58").End(xlUp).Offset(1, 0).Select
        ActiveSheet.Paste
    
        Sheets("Open").Select
        Range(closed_row).Select
        Selection.Delete Shift:=xlUp
        Range("B56:AK56").Select
        Selection.AutoFill Destination:=Range("B56:AK57"), Type:=xlFillDefault
        GoTo begin
    End If
    Next

jmp:
Application.ScreenUpdating = True
End Sub

Here is a portion of my spreadsheet:

Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAK
6Issue DescriptionAction To Be TakenPerformance Tracker
78D#Date OpenedStatusDescriptionAction To Be TakenProgressChampionPerson ResponsibleDate DueDate CompletedComplete On Time
8106811/11/16Closedfound damage to housing on 24315 and 24357to complete QRQCASKS1/21/161/21/16Yes
9106811/11/16Openfound damage to housing on 24315 and 24357Add sensor to driver slideASAS2/5/16
10106821/11/16Openfound adjuster 24569 stuck in the fully retracted positionReviewing the returned partIn QPBPB1/29/16 
11106801/6/16ClosedRust prior to 96 hoursLook at Plating specWe passed plating specMGMG1/22/161/22/16Yes
Open


I have tried to modify this by changing the ranges to reflect the new ranges, but I have no success. I appreciate any help.

Thanks!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Merged cells are the road to the Dark Side.
In all seriousness, it is a royal pain in the neck to do anything with merged cells. I highly recommend never using them unless you're doing a purely viusal worksheet. Moving them with code will almost always be fraught with problems.

My best recommendation would be to change column sizes and re-do this workbook with no merged cells. Royal pain, I'm sure, but that's what I'd do. If it's an option. Otherwise... No good suggestions. Sorry.
 
Upvote 0

Forum statistics

Threads
1,215,477
Messages
6,125,036
Members
449,205
Latest member
Eggy66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top