PC Review


Reply
Thread Tools Rate Thread

Any way to reduce/combine in this code?

 
 
ADK
Guest
Posts: n/a
 
      11th Jul 2007
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      11th Jul 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
ADK
Guest
Posts: n/a
 
      11th Jul 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I reduce repetative code leerem Microsoft Excel Misc 4 3rd Aug 2008 12:20 PM
How can I reduce repetative code leerem Microsoft Excel Programming 1 3rd Aug 2008 09:04 AM
Reduce code =?Utf-8?B?RXhjZWwgMjAwMyAtIFNQQg==?= Microsoft Excel Misc 2 10th May 2007 10:43 PM
reduce queries by using code anil Microsoft Access VBA Modules 2 27th Sep 2006 12:05 AM
Reduce Code Garry Jones Microsoft Access Getting Started 4 17th Jan 2006 09:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:32 PM.