Cactus1993
asked on
Adding to a VBA?
I have the following VBA that I want to add the exact same execution to, for cells B23 through O34. I am a complete newbie rookie to doing anything with these types of things ... but I do know the below works, and I just want to know how to add these cells to the same operation. Can you tell me how to it edit? Thanks so much in advance!:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A7:O34")) Is Nothing Then
On Error GoTo FallThrough
Application.EnableEvents = False
Dim a As Range
For Each a In Intersect(Target, Range("A7:O34"))
If IsNumeric(a.Value) Then _
If a.Value > 1 And a.Value Mod 100 < 60 And Int(a.Value / 100) < 24 Then _
a = TimeValue(Int(a.Value / 100) & ":" & Format(a.Value Mod 100, "00"))
Next a
End If
FallThrough:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A7:O34")) Is Nothing Then
On Error GoTo FallThrough
Application.EnableEvents = False
Dim a As Range
For Each a In Intersect(Target, Range("A7:O34"))
If IsNumeric(a.Value) Then _
If a.Value > 1 And a.Value Mod 100 < 60 And Int(a.Value / 100) < 24 Then _
a = TimeValue(Int(a.Value / 100) & ":" & Format(a.Value Mod 100, "00"))
Next a
End If
FallThrough:
Application.EnableEvents = True
End Sub
ASKER
Hi Subodh. Thanks -- I should have added more detail.
I only want the cell ranges B7:O18 and also B23:O34 in this VBA. (I do not want cells B19:O22 included.)
Thanks!
I only want the cell ranges B7:O18 and also B23:O34 in this VBA. (I do not want cells B19:O22 included.)
Thanks!
ASKER
My question should have looked like this:
I have the following VBA I want to exclude cells A19:O22 from. How do I do this?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A7:O34")) Is Nothing Then
On Error GoTo FallThrough
Application.EnableEvents = False
Dim a As Range
For Each a In Intersect(Target, Range("A7:O34"))
If IsNumeric(a.Value) Then _
If a.Value > 1 And a.Value Mod 100 < 60 And Int(a.Value / 100) < 24 Then _
a = TimeValue(Int(a.Value / 100) & ":" & Format(a.Value Mod 100, "00"))
Next a
End If
FallThrough:
Application.EnableEvents = True
End Sub
I have the following VBA I want to exclude cells A19:O22 from. How do I do this?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A7:O34")) Is Nothing Then
On Error GoTo FallThrough
Application.EnableEvents = False
Dim a As Range
For Each a In Intersect(Target, Range("A7:O34"))
If IsNumeric(a.Value) Then _
If a.Value > 1 And a.Value Mod 100 < 60 And Int(a.Value / 100) < 24 Then _
a = TimeValue(Int(a.Value / 100) & ":" & Format(a.Value Mod 100, "00"))
Next a
End If
FallThrough:
Application.EnableEvents = True
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow ... it was that easy. I told you I was a complete rookie newbie to VBAs!
Thank you!
Thank you!
Yes it was that easy. :)
You're welcome. Glad to help.
You're welcome. Glad to help.
If Not Intersect(Target, Range("A7:O34")) Is Nothing Then
The code will be effective for this range so if you want this code to work for the range B23:O34, change the range portion like this...
If Not Intersect(Target, Range("B23:O34")) Is Nothing Then