I have following code working fine but I am hoping it can be modified to make it run faster. Currently it takes almost five minutes to run.
I have two worksheets. Data tab gets new update of currently open projects. Active tab needs to be updated.
The basic idea is to update worksheet Active in two ways by looking at records in Data tab.
1. If the record does not exist in Active tab [new project], that row [from Data tab] gets added at the bottom of Active tab.
2. If the record exists than update columns B:X and Z:AG. (data in column Y needs to remain, it's a manual entry).
I have learned a lot here and I would really appreciate any tips I can get to optimize this code.
![]()
With Worksheets("Data") For x = 8 To lrd ‘ lrd is last row in Data tab which is around 850. If Worksheets("Data").Range("A" & x).Value = "No" Then 'Cell "A" & x has formula that results in Yes or No to indicate if the record exists. Worksheets("Data").Range("B" & x & ":AG" & x).Copy _ Destination:=Worksheets("Active").Range("B" & lra + 1) lra = lra + 1 ‘lra is last row used in worksheet Active Else a = .Range("AS" & x).Value ‘this cell has formula that calculates which row in Active sheet holds ‘ matching data. Worksheets("Data").Range("B" & x & ":X" & x).Copy _ Destination:=Worksheets("Active").Range("B" & a) Worksheets("Data").Range("Z" & x & ":AG" & x).Copy _ Destination:=Worksheets("Active").Range("Z" & a) End If Next x End With
Bookmarks