Need help in rewriting a 'merge columns' macro to run more efficiently

Shellecj

New Member
Joined
Aug 3, 2013
Messages
32
Could someone please examine this could code and advise if it could be rewritten more efficiently?

I've been using this same macro for over a year now but lately it's been taking much longer to run it's course as the number of records grows. The spreadsheet I'm using this macro is not really a huge worksheet of records (currently up to 480 rows). I also have several different worksheets for different purposes where I use a similar macro (each has a diff sub name to call with a different named range) and have a button setup on the main worksheet that when clicked, calls all 7 of these macros. This macro works just fine, however altogether to run through all of them is taking sometimes up to nearly 15 minutes.

Basically the purpose of this macro is to look down a certain column and if a cell is blank, I want it to copy the date from a previous column (for this particular macro, the date I want to copy is 6 rows back). I have the specific range of cells named with an offset formula with in the Names Manager, so refer to the column in the code with the name of the range instead (range("updated_Date")).

I do have quite a bit of records where I don't have a deadline date in either column, so am thinking that is in part what slows down this macro because it is essentially copying a blank value over to the destination column (range) but I don't know how to modify this code to account for this.

Below is an example of one of these macros. All 7 are pretty much the same except on some, the offset is only back one row or I resize the range, etc (e.g.: icell.Resize(1, 2).Value = icell.Resize(1, 2).Offset(0, -2).Value).

Any help would be greatly appreciated! Thanks!


Code:
 Sub Merge_Date_Columns()
Dim icell As Range
Application.ScreenUpdating = False
Sheets("Compliance").Select
    For Each icell In Range("Updated_Date")
        
        If icell.Value = "" Then
            icell.Value = icell.Offset(0, -6).Value
    
        End If
        
    Next icell
    
Application.ScreenUpdating = True
    
MsgBox "Macro Complete"
& vbLf _
& "Please press OK to continue."
End Sub
 
In the original code I posted, the range identified as "Updated_Date" refers to the last column on the right, labeled as "Extended
HUD Deadline"
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,215,001
Messages
6,122,648
Members
449,092
Latest member
peppernaut

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