LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default How are these uses of SpecialCells different?

I have two procedures that use SpecialCells(xlFormulas) to reduce a range to
only those cells that contain formulas. In the first instance the original
range is derived from a form and in the second it is derived from the user
selection. In testing these procedures out, only the first one is working.

The test cells contain the text 'alpha', 'beta', 'gamma', 'delta'. In the
first procedure I get a message box saying no formulas were found. In the
second I get an error later on in the procedure because the rest of the
procedure relys on formulas being present. I have looked at this for way
too long and can not find the problem.

Procedure 1:
bNoFormulas = False
If Range(frmAddServer.refInputRng.Value).Count 1 Then
On Error Resume Next
Set rngInput =
Range(frmAddServer.refInputRng.Value).SpecialCells (xlFormulas, 23)
On Error GoTo ErrorHandler
If rngInput Is Nothing Then 'There are no formulas in the range
bNoFormulas = True
End If
Else
Set rngInput = Range(frmAddServer.refInputRng.Value)
If Not rngInput.HasFormula Then
bNoFormulas = True
End If
End If

If bNoFormulas Then
MsgBox Prompt:=mcsMSG_NO_FORM, Buttons:=vbOKOnly + vbInformation,
Title:=mcsMODTITLE
Err.Raise glUSER_CANCEL
End If


Procedure 2 (not working):
On Error Resume Next
Set rngInput = Selection
On Error GoTo ErrorHandler

If rngInput Is Nothing Then
MsgBox Prompt:=mcsMSG_NO_SELECTION, Buttons:=vbOKOnly +
vbInformation, Title:=mcsMODTITLE
Err.Raise glUSER_CANCEL
End If

bNoFormulas = False
If rngInput.Count 1 Then
On Error Resume Next
Set rngInput = rngInput.SpecialCells(xlFormulas, 23)
On Error GoTo ErrorHandler

If rngInput Is Nothing Then 'There are no formulas in the range
bNoFormulas = True
End If
Else
If Not rngInput.HasFormula Then
bNoFormulas = True
End If
End If

If bNoFormulas Then
MsgBox Prompt:=mcsMSG_NO_FORM, Buttons:=vbOKOnly + vbInformation,
Title:=mcsMODTITLE
Err.Raise glUSER_CANCEL
End If


 
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 Value=0?? Otto Moehrbach Excel Programming 2 December 9th 06 02:23 PM
SpecialCells help Graham Y Excel Programming 2 October 11th 06 05:16 PM
SpecialCells mike Excel Programming 4 June 8th 06 01:50 AM
SpecialCells Peter Excel Programming 3 April 12th 06 02:03 PM
Specialcells Bruno Uato Charts and Charting in Excel 0 October 7th 05 07:42 PM


All times are GMT +1. The time now is 12:29 PM.

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

About Us

"It's about Microsoft Excel"