Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ADK ADK is offline
external usenet poster
 
Posts: 89
Default Any way to reduce/combine in this code?

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo addError
If Not (Application.Intersect(Target, Range("E7:H10000")) Is Nothing) Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
If Not (Application.Intersect(Target, Range("I7:J10000")) Is Nothing) Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
Exit Sub
addError:
Select Case Err
Case 13:
Exit Sub
Case Else:
Open ThisWorkbook.Path & "\ErrorLog.log" For Append As #2 'Open file
Print #2, Application.Text(Now(), "mm/dd/yyyy HH:mm") _
; Error(Err); Err 'Write data
Close #2 'Close

MsgBox "An error has occurred, contact John Doe (extension 123)"
End Select
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Any way to reduce/combine in this code?

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo addError
If Not (Application.Intersect(Target, Range("E7:J10000")) Is Nothing)
Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
Exit Sub
addError:
Select Case Err
Case 13:
Exit Sub
Case Else:
Open ThisWorkbook.Path & "\ErrorLog.log" For Append As #2 'Open file
Print #2, Application.Text(Now(), "mm/dd/yyyy HH:mm") _
; Error(Err); Err 'Write data
Close #2 'Close

MsgBox "An error has occurred, contact John Doe (extension 123)"
End Select
End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"ADK" wrote in message
...
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo addError
If Not (Application.Intersect(Target, Range("E7:H10000")) Is Nothing) Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
If Not (Application.Intersect(Target, Range("I7:J10000")) Is Nothing) Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
Exit Sub
addError:
Select Case Err
Case 13:
Exit Sub
Case Else:
Open ThisWorkbook.Path & "\ErrorLog.log" For Append As #2 'Open file
Print #2, Application.Text(Now(), "mm/dd/yyyy HH:mm") _
; Error(Err); Err 'Write data
Close #2 'Close

MsgBox "An error has occurred, contact John Doe (extension 123)"
End Select
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
ADK ADK is offline
external usenet poster
 
Posts: 89
Default Any way to reduce/combine in this code?

How about this? Not sure if it matters on time, having it only go as far as
the last row with values


Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo addError
Dim LastRow As String
LastRow = Range("V10000").End(xlUp).Row
LastRow = "E7:J" & LastRow
If Not (Application.Intersect(Target, Range(LastRow)) Is Nothing) Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
Exit Sub
addError:
Select Case Err
Case 13:
Exit Sub
Case Else:
Open ThisWorkbook.Path & "\ErrorLog.log" For Append As #2 'Open file
Print #2, Application.Text(Now(), "mm/dd/yyyy HH:mm") _
; Error(Err); Err 'Write data
Close #2 'Close

MsgBox "An error has occurred, contact Jeffrey Tocha (extension 359)"
End Select
End Sub



"Bob Phillips" wrote in message
...
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo addError
If Not (Application.Intersect(Target, Range("E7:J10000")) Is Nothing)
Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
Exit Sub
addError:
Select Case Err
Case 13:
Exit Sub
Case Else:
Open ThisWorkbook.Path & "\ErrorLog.log" For Append As #2 'Open file
Print #2, Application.Text(Now(), "mm/dd/yyyy HH:mm") _
; Error(Err); Err 'Write data
Close #2 'Close

MsgBox "An error has occurred, contact John Doe (extension 123)"
End Select
End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"ADK" wrote in message
...
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo addError
If Not (Application.Intersect(Target, Range("E7:H10000")) Is Nothing)
Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
If Not (Application.Intersect(Target, Range("I7:J10000")) Is Nothing)
Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If
Exit Sub
addError:
Select Case Err
Case 13:
Exit Sub
Case Else:
Open ThisWorkbook.Path & "\ErrorLog.log" For Append As #2 'Open
file
Print #2, Application.Text(Now(), "mm/dd/yyyy HH:mm") _
; Error(Err); Err 'Write data
Close #2 'Close

MsgBox "An error has occurred, contact John Doe (extension 123)"
End Select
End Sub





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
How can I reduce repetative code leerem Excel Discussion (Misc queries) 4 August 3rd 08 12:20 PM
Reduce code Excel 2003 - SPB Excel Discussion (Misc queries) 2 May 10th 07 10:43 PM
Reduce file size by removing comments from code? Shadhi Excel Programming 2 May 26th 05 09:42 PM
How to combine lines of code? Papa Jonah Excel Programming 2 February 17th 05 08:23 AM
Combine Code Steph[_3_] Excel Programming 2 January 23rd 04 08:19 PM


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