Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default SpecialCells

Thanks for the help of Norman and Dave at
http://msdn.microsoft.com/newsgroups...=en-us&m=1&p=1

Now, I have another follow up question about formula in Excel worksheet.

I got a "No Cells were found" error if I use Active Sheet.SpecialCells()
method to retrieve all formulae on a worksheet. I suspect that this error
happen because I try to retrieve "nothing" if a worksheet have NO formula at
all. However, how can I skip this worksheet and then go on to next
worksheets?

Thanks,
Peter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default SpecialCells

First you should check if there are any formulas something like this...

dim cell as range
dim rngFormulas as range

on error resume next
set rngFormulas = cells.specialcells(xlCellTypeFormulas)
on error goto 0

if rngformulas is nothing then
msgbox "Sorry, No formulas."
else
for each cell in rngformulas
msgbox cell.Address
next cell
end if

--
HTH...

Jim Thomlinson


"Peter" wrote:

Thanks for the help of Norman and Dave at
http://msdn.microsoft.com/newsgroups...=en-us&m=1&p=1

Now, I have another follow up question about formula in Excel worksheet.

I got a "No Cells were found" error if I use Active Sheet.SpecialCells()
method to retrieve all formulae on a worksheet. I suspect that this error
happen because I try to retrieve "nothing" if a worksheet have NO formula at
all. However, how can I skip this worksheet and then go on to next
worksheets?

Thanks,
Peter

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default SpecialCells

Hi Peter,

if Cells.SpecialCells(xlCellTypeFormulas) is nothing then ....

--
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Peter" wrote in message ...
Thanks for the help of Norman and Dave at

http://msdn.microsoft.com/newsgroups...=en-us&m=1&p=1

Now, I have another follow up question about formula in Excel worksheet.

I got a "No Cells were found" error if I use Active Sheet.SpecialCells()
method to retrieve all formulae on a worksheet. I suspect that this error
happen because I try to retrieve "nothing" if a worksheet have NO formula at
all. However, how can I skip this worksheet and then go on to next
worksheets?

Thanks,
Peter



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default SpecialCells

Norman's code did skip to the next worksheet:

Public Sub Tester002()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range

Set WB = Workbooks("Book1.xls") '<<==== CHANGE

For Each SH In WB.Worksheets
set rng = nothing '<-- added
On Error Resume Next
Set rng = SH.Cells.SpecialCells(xlCellTypeFormulas)
On Error GoTo 0

If Not rng Is Nothing Then
For Each rCell In rng.Cells
'do someting. e.g.:
rCell.Interior.ColorIndex = 6
Next rCell
End If
Next SH

End Sub

You may want to post the code you actually used if this doesn't help.

Peter wrote:

Thanks for the help of Norman and Dave at
http://msdn.microsoft.com/newsgroups...=en-us&m=1&p=1

Now, I have another follow up question about formula in Excel worksheet.

I got a "No Cells were found" error if I use Active Sheet.SpecialCells()
method to retrieve all formulae on a worksheet. I suspect that this error
happen because I try to retrieve "nothing" if a worksheet have NO formula at
all. However, how can I skip this worksheet and then go on to next
worksheets?

Thanks,
Peter


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Specialcells Bruno Uato Charts and Charting in Excel 0 October 7th 05 07:42 PM
SpecialCells(xlLastCell) José Ignacio Bella Excel Programming 12 January 9th 05 07:20 PM
SpecialCells(xlCellTypeLastCell) Tom Ogilvy Excel Programming 0 July 21st 04 03:37 PM
SpecialCells(xlCellTypeFormulas) Kevin Gabbert Excel Programming 1 January 28th 04 05:06 PM
AutoFilter /specialcells Ron de Bruin Excel Programming 8 January 13th 04 03:45 PM


All times are GMT +1. The time now is 09:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"