Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Why is Cell not an object

Morning All,

Philosophical rather than practical question - I'm auditing all my
code and trying to be as explicit as possible with my variable
declarations. So really trying to avoid using Variant. I use the
following structure quite a bit:

Dim myCell
For Each myCell In .Sheets("Static").Range("xxx").Cells
If myCell < "" Then
'code to execute here on each cell if cell not empty
End If
Next

myCell is a variant but I'd prefer to declare it as a specific data
type or object so that the code is more precise.

Any help appreciated
Jason.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Why is Cell not an object

I'm not sure if I understand your question, but I'd use:

Dim myCell as Range

And I'd be explicit:
if mycell.value < "" then
or
if isempty(mycell.value) then

A cell containing a formula evaluating to "" would satisfy the first condition,
but not the second.

And a cell containing that formula that was converted to a value would behave
the same!

On 07/01/2011 03:38, WhytheQ wrote:
Morning All,

Philosophical rather than practical question - I'm auditing all my
code and trying to be as explicit as possible with my variable
declarations. So really trying to avoid using Variant. I use the
following structure quite a bit:

Dim myCell
For Each myCell In .Sheets("Static").Range("xxx").Cells
If myCell< "" Then
'code to execute here on each cell if cell not empty
End If
Next

myCell is a variant but I'd prefer to declare it as a specific data
type or object so that the code is more precise.

Any help appreciated
Jason.


--
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
Can information from a cell be placed over the top of an object? jwt Excel Discussion (Misc queries) 0 July 15th 08 05:31 PM
Cell and Object change JakeShipley2008 Excel Discussion (Misc queries) 1 June 9th 08 07:22 PM
Cutting cell with object ZipCurs Excel Programming 1 April 10th 07 07:42 PM
Move shape, object, pic to center of new cell based on cell value zzxxcc Excel Programming 4 July 7th 06 12:58 PM
Dynamically adding an in-cell drop-down list (i.e. Validation Object) to a cell? debartsa Excel Programming 5 March 5th 04 08:45 AM


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