VerifiedBleachersAttendee
New Member
- Joined
- May 10, 2024
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi all,
I am trying to have a macro in my workbook copy data from a column AA and paste it in a different column AB skipping non-blanks, so that if say AB100 is not empty my code won't do anything but move on to copying AA101 into AB101 and so on.
Thing is, depending on the parameters the workbook can load up to 4000 rows and this check is making the execution extremely slow, peaking at 20 mins.
Bypassing the check makes the copy and paste a matter of seconds, but it is required that destination cells that are already filled remain unchanged.
What can I do to make my code run faster?
Here's a snippet of the macro:
I am trying to have a macro in my workbook copy data from a column AA and paste it in a different column AB skipping non-blanks, so that if say AB100 is not empty my code won't do anything but move on to copying AA101 into AB101 and so on.
Thing is, depending on the parameters the workbook can load up to 4000 rows and this check is making the execution extremely slow, peaking at 20 mins.
Bypassing the check makes the copy and paste a matter of seconds, but it is required that destination cells that are already filled remain unchanged.
What can I do to make my code run faster?
Here's a snippet of the macro:
Excel Formula:
Dim lastrow As Long
Dim rowCounter As Integer
lastrow = ActiveWorkbook.ActiveSheet.Range("H16").End(xlDown).Row
If lastrow > 60000 Then lastrow = 16
Application.ScreenUpdating = False
For rowCounter = 0 To lastrow
If Range("AB" & 16 + rowCounter).Value2 = "" Then
Range("AB" & 16 + rowCounter).Value2 = Range("AA" & 16 + rowCounter).Value2
End If