nyconfidential
New Member
- Joined
- Jul 22, 2015
- Messages
- 49
- Office Version
- 365
- 2016
Hi all - working on a function that copies formulas from one worksheet to another. I'm looping through every sheet in the workbook - when I get to a sheet that has no formulas, I get that "1004 - No cells Found" error. Now I guess I can handle this through error handling, but is there a simple way to determine if a sheet has formulas before I start the meat of my sub? I'm trying an If statement at the moment(If ThisWorkbook.Sheets(rCell.Value).Cells.SpecialCells(xlCellTypeFormulas).count > 0 Then), but that isn't working(I get the same 1004 error when I step through that line). Anyone have any thoughts? Thanks in advance.
Code:
For Each rCell In rRng.Cells
If SheetExists(rCell.Value) = True Then
Application.DisplayAlerts = False
Application.ScreenUpdating = False
If ThisWorkbook.Sheets(rCell.Value).Cells.SpecialCells(xlCellTypeFormulas).count > 0 Then
For Each r In ThisWorkbook.Sheets(rCell.Value).Cells.SpecialCells(xlCellTypeFormulas)
ActiveWorkbook.Sheets(rCell.Value).Range(r.Address).Formula _
= ThisWorkbook.Sheets(rCell.Value).Range(r.Address).Formula
Next r
End If
Next rCell
Last edited: