Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Problem when hitting an empty cell

GPrabaka wrote:
I am running into a problem. I have the following code
dim counter as integer
counter = 0
Do While .ActiveCell.Offset(counter, 0).Value < ""
If .ActiveCell.Offset(counter, 22).Value < "" Then
.ActiveCell.EntireRow.Delete()
End If
counter = counter + 1
Loop
If .ActiveCell.Offset(counter,22) is empty, which should be valid, it
returns a fatal error "Cast from String "" to type 'Double' is not valid".
I have tried formatting that column to text, currency etc. I still hit the
same error.


your code seems to be written in VB.NET. if so, try

Do While Not IsNothing(.ActiveCell.Offset(counter, 0).Value)
If Not IsNothing(.ActiveCell.Offset(counter, 22).Value) Then

or

Do While CStr(.ActiveCell.Offset(counter, 0).Value) < ""
If CStr(.ActiveCell.Offset(counter, 22).Value) < "" Then

--
HTH,

okaizawa
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
Cell changes to a formula after hitting ENTER PerryK Excel Discussion (Misc queries) 4 October 8th 08 05:14 PM
Linking 2 worksheets-Empty cell problem NM Excel Discussion (Misc queries) 4 October 1st 08 02:50 PM
problem of an empty cell octet Excel Discussion (Misc queries) 5 September 3rd 08 05:16 PM
Problem Dropping data in first Empty Cell and across the row Ligaya Excel Programming 2 December 8th 04 06:21 PM
automatically advance to next cell without hitting enter or tab corby Excel Programming 4 May 29th 04 03:09 AM


All times are GMT +1. The time now is 01:16 AM.

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"