Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Probklem with code, when merged cells

I have the folowwing code, and it works ok in most cases:

Private Sub Worksheet_Change(ByVal Target As Range)
If ((Target.Column = 10) Or (Target.Column = 15)) Then
If Not IsEmpty(Target) Or Target < "" Then
MsgBox "The cell content has been changed"
End If
End If
End Sub

But if I delete something from a merged cell, in stead of just skipping the
cell (not displaying the messagebox) I get a "Run-Time error '13': Type
mismatch". This only happens on merged cells.

Any idea how to avoid this?

Jan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Probklem with code, when merged cells

Try this

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 10 Or Target.Column = 15 Then
If Not IsEmpty(Target) Or Target < "" Then
MsgBox "The cell content has been changed"
End If
End If
End Sub

Mike

"Jan Kronsell" wrote:

I have the folowwing code, and it works ok in most cases:

Private Sub Worksheet_Change(ByVal Target As Range)
If ((Target.Column = 10) Or (Target.Column = 15)) Then
If Not IsEmpty(Target) Or Target < "" Then
MsgBox "The cell content has been changed"
End If
End If
End Sub

But if I delete something from a merged cell, in stead of just skipping the
cell (not displaying the messagebox) I get a "Run-Time error '13': Type
mismatch". This only happens on merged cells.

Any idea how to avoid this?

Jan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Probklem with code, when merged cells

Thank you. That did it :-)

Jan

Jan Kronsell wrote:
I have the folowwing code, and it works ok in most cases:

Private Sub Worksheet_Change(ByVal Target As Range)
If ((Target.Column = 10) Or (Target.Column = 15)) Then
If Not IsEmpty(Target) Or Target < "" Then
MsgBox "The cell content has been changed"
End If
End If
End Sub

But if I delete something from a merged cell, in stead of just
skipping the cell (not displaying the messagebox) I get a "Run-Time
error '13': Type mismatch". This only happens on merged cells.

Any idea how to avoid this?

Jan



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
merged cells - code glitch Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 9 October 10th 07 09:27 PM
Autofit Merged cell Code is changing the format of my merged cells JB Excel Discussion (Misc queries) 0 August 20th 07 02:12 PM
Problem with code for merged cells SuitedAces[_25_] Excel Programming 5 July 7th 06 09:40 PM
changing merged cells from code john Excel Programming 7 July 6th 05 10:24 PM
Code doesn't work on merged cells IC[_2_] Excel Programming 8 September 10th 04 12:55 PM


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