cmpgeek
New Member
- Joined
- Dec 4, 2003
- Messages
- 8
I have some VBA code that someone helped me with years ago that works great 99% of the time. For some reason, When I try to delete one cell from all the spreadsheets within the workbook at once - or do a replace all on a highlighted group of cells (again - on all spreadsheets at once) I get the run-time error. (I can do the changes one sheet at a time, but there are close to 80 sheets so it is really more efficient if I can avoid that).
I am now using Excel 2010. This was written when I was using Excel 2000. (I don't know if that will matter or not).
I am using Microsoft Visual Basics for Applications 7.0
When I hit the button to Debug the code this is where the problem is highlighted:
[highlight] If Intersect(Target, Range("G:AC")) Is Nothing Then [/highlight] Exit Sub
What little I know about VBA is from a "Teach Yourself" book and from examples I have found on similiar forums... I haven't really had the chance to break this code down line by line to be able to understand it, so please forgive me if this is something simple to yall...
Thanks so much...
I am now using Excel 2010. This was written when I was using Excel 2000. (I don't know if that will matter or not).
I am using Microsoft Visual Basics for Applications 7.0
Code:
Option Explicit
Sub MyWsChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("G:AC")) Is Nothing Then Exit Sub
On Error GoTo errHandler:
With Target
If IsNumeric(.Value) Then
Application.EnableEvents = False
Select Case .Value
Case 0
.NumberFormat = "[h]:mm"
Case 1 To 99
.Value = TimeSerial(0, .Value, 0)
.NumberFormat = "[h]:mm"
Case 100 To 9999
.Value = TimeSerial(Int(.Value / 100), .Value Mod 100, 0)
.NumberFormat = "[h]:mm"
Case Else
End Select
End If
End With
errHandler:
Application.EnableEvents = True
End Sub
When I hit the button to Debug the code this is where the problem is highlighted:
[highlight] If Intersect(Target, Range("G:AC")) Is Nothing Then [/highlight] Exit Sub
What little I know about VBA is from a "Teach Yourself" book and from examples I have found on similiar forums... I haven't really had the chance to break this code down line by line to be able to understand it, so please forgive me if this is something simple to yall...
Thanks so much...