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

I want to step through a range clearing the contents of
cells with number values, but not formulas. The following
code doesn't work:

If ActiveCell.Offset(currow - 1, 0).Type <
xlCellTypeFormulas Then
ActiveCell.Offset(currow - 1, 0).ClearContents
End If

Does the constant "xlcelltypeformulas" only work with
the "specialCells" method? Is there another solution?

DM


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default test a cells type

If the range you want to process is selected you could use the following

Sub ClearCells()
Dim cell As Range
For Each cell In Selection.SpecialCells(xlCellTypeConstants)
cell.ClearContents
Next cell
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default test a cells type

Dick,

Want to try this instead?

Dim cell As Range

For Each cell In Selection
If Not cell.HasFormula Then
cell.ClearContents
End If
Next cell


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Dick Minter" wrote in message
...
I want to step through a range clearing the contents of
cells with number values, but not formulas. The following
code doesn't work:

If ActiveCell.Offset(currow - 1, 0).Type <
xlCellTypeFormulas Then
ActiveCell.Offset(currow - 1, 0).ClearContents
End If

Does the constant "xlcelltypeformulas" only work with
the "specialCells" method? Is there another solution?

DM




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
How to add time from multiple cells & date Cells & machine type c Peter Gonzalez[_2_] Excel Worksheet Functions 3 January 28th 10 11:48 PM
Logical Test with multiple cells Deanna Excel Worksheet Functions 2 October 20th 08 03:34 AM
Test for coloured cells? Becks Excel Discussion (Misc queries) 5 February 9th 06 04:18 AM
Test for data in a range of cells Spike9458 Excel Worksheet Functions 4 January 20th 06 09:06 PM
an error.type test Maileen Excel Worksheet Functions 0 June 23rd 05 07:56 AM


All times are GMT +1. The time now is 03:30 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"