Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Code ends subroutine in error

The code below is evaluating a cell containing either a
blank or a dollar amount expressed without a decimal point
($10.00 = 1000).

If ActiveCell.Offset(0, 2) = "" Then
DrAmtAcct = ""
Else
If ActiveCell.Offset(0, 2) 0 Then
DrAmtAcct = Abs(ActiveCell.Offset(0, 2))
End If
End If

The problem I'm having is that when it gets to the cell
with a blank (no data), the routine ends.

Any help in figuring out why this is happening would be
greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Code ends subroutine in error

Mike

What do you want it to do if it finds a blank cell?

What is happening at the moment is, if it finds a blank cell,
DrAmtAcct = "" , then it goes to the last End If and exits.

So, what do you want it to do now?........

Henry


"Mike" wrote in message
...
The code below is evaluating a cell containing either a
blank or a dollar amount expressed without a decimal point
($10.00 = 1000).

If ActiveCell.Offset(0, 2) = "" Then
DrAmtAcct = ""
Else
If ActiveCell.Offset(0, 2) 0 Then
DrAmtAcct = Abs(ActiveCell.Offset(0, 2))
End If
End If

The problem I'm having is that when it gets to the cell
with a blank (no data), the routine ends.

Any help in figuring out why this is happening would be
greatly appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Code ends subroutine in error

Hi,

Are you sure that cell is really empty. There could be space(s) in the cell.

did you step the code? if it stops and gives an error on line "DrAmtAcct = Abs(ActiveCell.Offset(0, 2))", possibly the reason cell has space(s) and not empty.
just change that line to "DrAmtAcct = Abs(Val(ActiveCell.Offset(0, 2)))" and try again.


--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.



"Mike" , iletide sunu yazdi ...
The code below is evaluating a cell containing either a
blank or a dollar amount expressed without a decimal point
($10.00 = 1000).

If ActiveCell.Offset(0, 2) = "" Then
DrAmtAcct = ""
Else
If ActiveCell.Offset(0, 2) 0 Then
DrAmtAcct = Abs(ActiveCell.Offset(0, 2))
End If
End If

The problem I'm having is that when it gets to the cell
with a blank (no data), the routine ends.

Any help in figuring out why this is happening would be
greatly appreciated.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Code ends subroutine in error


Hi,

Another possibility could be; prior to that code, did you declare DrAmtAcct variable in the Sub or Module. If it is already declared as integer/long/double/currency, you get an error when the cell is blank. because the code is trying to assign a string value to DrAmtAcct variable.


--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.



"Haldun Alay" <haldunalayATyahooDOTcom, iletide sunu yazdi ...
Hi,

Are you sure that cell is really empty. There could be space(s) in the cell.

did you step the code? if it stops and gives an error on line "DrAmtAcct = Abs(ActiveCell.Offset(0, 2))", possibly the reason cell has space(s) and not empty.
just change that line to "DrAmtAcct = Abs(Val(ActiveCell.Offset(0, 2)))" and try again.


--
Regards

Haldun Alay

To e-mail me, please remove AT and DOT from my e-mail address.



"Mike" , iletide sunu yazdi ...
The code below is evaluating a cell containing either a
blank or a dollar amount expressed without a decimal point
($10.00 = 1000).

If ActiveCell.Offset(0, 2) = "" Then
DrAmtAcct = ""
Else
If ActiveCell.Offset(0, 2) 0 Then
DrAmtAcct = Abs(ActiveCell.Offset(0, 2))
End If
End If

The problem I'm having is that when it gets to the cell
with a blank (no data), the routine ends.

Any help in figuring out why this is happening would be
greatly appreciated.
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
Call a subroutine using variable subroutine name dhstein Excel Discussion (Misc queries) 3 July 26th 09 08:28 PM
SUBROUTINE HELP biker man Excel Discussion (Misc queries) 1 July 28th 07 04:06 PM
filter using "ends with" and 3 choices? Ex: ends with 1,2 or3 Debbie Excel Worksheet Functions 1 April 6th 07 12:07 AM
Every second subroutine dolegow Excel Programming 1 October 12th 03 02:11 AM
How do I run a subroutine on a worksheet Myron Excel Programming 3 September 8th 03 09:54 PM


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