VBA - Stuck in Loop?

jamada

Active Member
Joined
Mar 23, 2006
Messages
323
Hello, I have the following code that when used without the date part works just great, HOWEVER with the date it appears to just go into a loop and the screen justs flashes as the ranges are repainted.

Can someone see a problem with the date? or anything else perhaps?
Thank You


Private Sub Worksheet_Change(ByVal Target As Range)


If Intersect(Target, Range("A1:I29")) Is Nothing Then Exit Sub ' not wanted

Dim myString As Range
Set myString = Range("A1")
Range("A1") = ThisWorkbook.Name
myString = Left(myString, Len(myString) - 4) 'Change number depending on saved version either 2003 or 2007
Range("B13") = Range("A1") + 1


' 1) The Following Code changes ALL Border line colors to white (color Themecolor 1)
Range("A3:I29").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone

With Selection.Borders
.LineStyle = xlContinuous
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 2
End With


'3)The Following Frames each required range.
Range("A4:A7,B4:B7,D4:D7,E4:E7,G4:G7,H4:H7,A8:A11,B8:B11,G8:G11,H8:H11,D13:D16,E13:E16,G13:G16,H13:H16,D17:D20,E17:E20,G17:G20,H17:H20,A22:A25,B22:B25,G22:H29,A26:A29,B26:B29").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone

With Selection.Borders
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With

Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone


'4) Within the following range, color background "Yellow"
Range("A1").Select


End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)


If Intersect(Target, Range("A1:I29")) Is Nothing Then Exit Sub ' not wanted
Application.EnableEvents = False
Dim myString As Range
Set myString = Range("A1")
Range("A1") = ThisWorkbook.Name
myString = Left(myString, Len(myString) - 4) 'Change number depending on saved version either 2003 or 2007
Range("B13") = Range("A1") + 1


' 1) The Following Code changes ALL Border line colors to white (color Themecolor 1)
Range("A3:I29").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone

With Selection.Borders
.LineStyle = xlContinuous
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 2
End With


'3)The Following Frames each required range.
Range("A4:A7,B4:B7,D4:D7,E4:E7,G4:G7,H4:H7,A8:A11,B8:B11,G8:G11,H8:H11,D13:D16,E13:E16,G13:G16,H13:H16,D17:D20,E17:E20,G17:G20, H17:H20,A22:A25,B22:B25,G22:H29,A26:A29,B26:B29").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone

With Selection.Borders
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With

Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone


'4) Within the following range, color background "Yellow"
Range("A1").Select

Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,375
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top