Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default If Target="" error

Excel 2002, Win XP
I have a short WorkSheet_Change macro as below:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F29:J29", "F93")) Is Nothing Then Exit Sub
If Target = "" Then Exit Sub
'Call a macro
End Sub

I'm getting a Type Mismatch error on:
If Target = "" Then Exit Sub
and only the 'If Target="" Then' is highlighted

I think I've done this before without the error. Maybe I'm thinking of a
regular macro.
What I want to do is Exit Sub if Target is blank.
Where did I go wrong?
Thanks for your help. Otto


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default If Target="" error

Either:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.count 1 then exit sub
If Intersect(Target, Range("F29:J29", "F93")) Is Nothing Then Exit Sub
If isempty(Target) Then Exit Sub
'Call a macro
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 then exit sub
If Intersect(Target, Range("F29:J29", "F93")) Is Nothing Then Exit Sub
If len(trim(Target)) = 0 Then Exit Sub
'Call a macro
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.count 1 then exit sub
If Intersect(Target, Range("F29:J29", "F93")) Is Nothing Then Exit Sub
If Target.Text = "" Then Exit Sub
'Call a macro
End Sub


If you want to process a multi cell area for Target, then you will have to
add code to specifically deal with that.

Range("A1").Resize(2,1) = ""

will raise a type mismatch error since you are comparing an array to a
string.

--
Regards,
Tom Ogilvy


Otto Moehrbach wrote in message
...
Excel 2002, Win XP
I have a short WorkSheet_Change macro as below:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F29:J29", "F93")) Is Nothing Then Exit Sub
If Target = "" Then Exit Sub
'Call a macro
End Sub

I'm getting a Type Mismatch error on:
If Target = "" Then Exit Sub
and only the 'If Target="" Then' is highlighted

I think I've done this before without the error. Maybe I'm thinking of a
regular macro.
What I want to do is Exit Sub if Target is blank.
Where did I go wrong?
Thanks for your help. Otto




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default If Target="" error

Tom
What you pointed out seems so obvious once I see it. Thanks for the
help, as always. Otto
"Tom Ogilvy" wrote in message
...
Either:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.count 1 then exit sub
If Intersect(Target, Range("F29:J29", "F93")) Is Nothing Then Exit Sub
If isempty(Target) Then Exit Sub
'Call a macro
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 then exit sub
If Intersect(Target, Range("F29:J29", "F93")) Is Nothing Then Exit Sub
If len(trim(Target)) = 0 Then Exit Sub
'Call a macro
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.count 1 then exit sub
If Intersect(Target, Range("F29:J29", "F93")) Is Nothing Then Exit Sub
If Target.Text = "" Then Exit Sub
'Call a macro
End Sub


If you want to process a multi cell area for Target, then you will have to
add code to specifically deal with that.

Range("A1").Resize(2,1) = ""

will raise a type mismatch error since you are comparing an array to a
string.

--
Regards,
Tom Ogilvy


Otto Moehrbach wrote in message
...
Excel 2002, Win XP
I have a short WorkSheet_Change macro as below:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F29:J29", "F93")) Is Nothing Then Exit

Sub
If Target = "" Then Exit Sub
'Call a macro
End Sub

I'm getting a Type Mismatch error on:
If Target = "" Then Exit Sub
and only the 'If Target="" Then' is highlighted

I think I've done this before without the error. Maybe I'm thinking of

a
regular macro.
What I want to do is Exit Sub if Target is blank.
Where did I go wrong?
Thanks for your help. Otto






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
"num#" errors .. how to average a group with a "num#" error Byron Excel Discussion (Misc queries) 3 May 20th 09 04:32 AM
"Document not saved" "error in loading DLL" Tracey L Excel Discussion (Misc queries) 0 December 1st 08 12:57 PM
How to insert a "Target" line into basic bar chart keith666 Charts and Charting in Excel 1 October 5th 08 08:00 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Shortcut key for "Paste Options" and "Error Checking" buttons? johndog Excel Discussion (Misc queries) 1 October 6th 06 11:56 AM


All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"