VBA copy but ignore blank cells that have formulas

4653

New Member
Joined
Apr 20, 2012
Messages
22
I have a copy button that is supposed to copy a range but only the cells that contain data and I'm currently using CurrentRegion but that doesn't ignore the cells that are blank with formulas in them. The formulas go from A1:H44 but columns A through H are merged so it's really just A1:A44. Below is the code I'm currently using. Does anyone know how to copy just cells that have data and ignore formulas? The rows it copies change from day to day. One day rows 1-5 might have data in them, the next it might be rows 1-44 and the next day it could be rows 1-20. The data will always start in row 1 and will always be continuous downward until it is blank (except the formulas of course).

Application.ScreenUpdating = False
Sheets("Auto Review Notes").Range("A1").CurrentRegion.cOPY
Sheets("Auto Review").Select
Range("C2").Select
Application.ScreenUpdating = True
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

drsarao

Well-known Member
Joined
Sep 9, 2009
Messages
1,141
Try this:
VBA Code:
Sub nonblankcopy()
Application.ScreenUpdating = False
With Sheets("Auto Review Notes")
    lr = .Range("A:A").Find("*", , xlValues, , xlByRows, xlPrevious).Row
    .Range("A1:A" & lr).Copy
End With
Sheets("Auto Review").Select
Range("C2").Select
Application.ScreenUpdating = True
End Sub
 

4653

New Member
Joined
Apr 20, 2012
Messages
22
Try this:
VBA Code:
Sub nonblankcopy()
Application.ScreenUpdating = False
With Sheets("Auto Review Notes")
    lr = .Range("A:A").Find("*", , xlValues, , xlByRows, xlPrevious).Row
    .Range("A1:A" & lr).Copy
End With
Sheets("Auto Review").Select
Range("C2").Select
Application.ScreenUpdating = True
End Sub
That worked perfect. Thanks so much. I tried several different things online and couldn't find anything that worked.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,878
Messages
5,544,831
Members
410,638
Latest member
Satishj013
Top