VBA copy but ignore blank cells that have formulas

4653

New Member
Joined
Apr 20, 2012
Messages
27
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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