Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Blank Values


Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2004, 03:43 AM
rudekid rudekid is offline
Regular
 
Join Date: Sep 2003
Posts: 54
Default Blank Values


Scratching my head on this one:

I have a column for which each cell contains an Excel formulae that returns a number OR blank when calculated. Depending on whether this number is greater or smaller than an earlier variable the user has set at the beginning of the procedure using an input box - Max - defines how my subroutine treats each row that's rather crucial to the whole point of my program.

The functions aren't important, what is important is getting my code to recognise blanks. My input box type has been set to 1, i.e. the user has to enter a number. My If statement looks like this:

If book1.Cells(RowNum, 31).Value > Max Then
book1.Range(book1.Cells(RowNum, 32), book1.Cells(RowNum, 32)).Value = "Deleted"

However: it treats a blank cell as > Max and flags it "deleted". I've tried copying and pasting the column as XLvalues, (i.e. deleting the function and leaving only the numbers or a blank) but it still treats each apparently blank cell as greater than Max.

Can anybody help? thx
Reply With Quote
  #2  
Old 10-12-2004, 03:50 AM
planetwise's Avatar
planetwise planetwise is offline
Regular
 
Join Date: Jun 2004
Location: Groningen, Netherlands
Posts: 75
Default

Try a msgbox to show you what value is read?
__________________
Don't declare my string in public, it isn't integer.
Reply With Quote
  #3  
Old 10-12-2004, 03:53 AM
Wheels1978 Wheels1978 is offline
Junior Contributor
 
Join Date: Apr 2004
Location: 's-Gravenpolder, NL
Posts: 389
Default

Try
Code:
If book1.cells(RowNum,31).value<>"" then If book1.Cells(RowNum, 31).Value > Max Then book1.Range(book1.Cells(RowNum, 32), book1.Cells(RowNum, 32)).Value = "Deleted" End If End If

Maybe you should also refer to your range using
Code:
Workbooks(book1).Worksheets("YourSheetName").Cells(RowNum,31) 'or ActiveWorkbook.Worksheets("YourSheetName").Cells(RowNum,31)

I assume that book1 is a new book. book1 should be book1.xls if it is already saved.

Just in case you get errors on your references.
__________________
"Accept what you can not change and change what you can not accept" - Me
"Normal is the average of all oddities" - Me
"Don't re-invent the wheel!" - My dad
Please enclose your code in [vb] and [/vb] tags
Reply With Quote
  #4  
Old 10-12-2004, 03:55 AM
malloc malloc is offline
Senior Contributor
 
Join Date: Feb 2004
Location: The land of Oz
Posts: 851
Default

If by Blank you mean there's a space in the cell, then that may be the problem.
A space is bigger than a number in the evaluation.
__________________
malloc

-| Use [vb][/vb] tags | Forum guidelines | Get FireFox | Google |-
Reply With Quote
  #5  
Old 10-12-2004, 05:52 AM
planetwise's Avatar
planetwise planetwise is offline
Regular
 
Join Date: Jun 2004
Location: Groningen, Netherlands
Posts: 75
Default

Quote:
have a column for which each cell contains an Excel formulae that returns a number OR blank when calculated
Can you also give the formula?
Malloc's comment makes sence, maybe your formula is the problem...
__________________
Don't declare my string in public, it isn't integer.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->