#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Connie Martin
 
Posts: n/a
Default Run-Time Error

The following macro gives me a "run-time error '13' Type mismatch" pop-up
when I delete row. When I click on Debug it is the ".Value=UCase(.Value)"
that's highlighted. What is wrong? Connie

Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is
Nothing) Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Run-Time Error

Since you're deleting a row, you're changing the cell in column B and F. Two
cells don't have a simple value you can check.

I think I'd look for multiple cells and quit if I find them:

Private Sub Worksheet_Change(ByVal Target As Range)
if target.cells.count 1 then exit sub
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is Nothing) _
Then
With Target
If Not .HasFormula Then
application.enableevents = false
.Value = UCase(.Value)
application.enableevents = true
End If
End With
End If
End Sub

The .enableevents stop the change from firing the code again.

Connie Martin wrote:

The following macro gives me a "run-time error '13' Type mismatch" pop-up
when I delete row. When I click on Debug it is the ".Value=UCase(.Value)"
that's highlighted. What is wrong? Connie

Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is
Nothing) Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Connie Martin
 
Posts: n/a
Default Run-Time Error

Thank you very much. That works very nicely. Connie

"Dave Peterson" wrote:

Since you're deleting a row, you're changing the cell in column B and F. Two
cells don't have a simple value you can check.

I think I'd look for multiple cells and quit if I find them:

Private Sub Worksheet_Change(ByVal Target As Range)
if target.cells.count 1 then exit sub
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is Nothing) _
Then
With Target
If Not .HasFormula Then
application.enableevents = false
.Value = UCase(.Value)
application.enableevents = true
End If
End With
End If
End Sub

The .enableevents stop the change from firing the code again.

Connie Martin wrote:

The following macro gives me a "run-time error '13' Type mismatch" pop-up
when I delete row. When I click on Debug it is the ".Value=UCase(.Value)"
that's highlighted. What is wrong? Connie

Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Target, Range("B18:B100,F18:F100")) Is
Nothing) Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
End Sub


--

Dave Peterson

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
Excel Time Manipulation BFiedler Excel Discussion (Misc queries) 0 September 15th 05 01:15 AM
conditional formatting with time values Access Idiot Excel Discussion (Misc queries) 2 September 13th 05 03:29 PM
Help needed with Run Time Error 1004 Manesh Excel Discussion (Misc queries) 0 April 4th 05 05:07 AM
Time Sheets Lady Layla Excel Discussion (Misc queries) 1 March 23rd 05 03:22 PM
How do you sum a range of more than 30 cells. I get error each time I try. Joseph Conaghan via OfficeKB.com Excel Worksheet Functions 5 March 21st 05 10:15 PM


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