Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default macro hangs if no data is found

Thanks everyone for your help - I have found the problem. I was
convinced the issue was in the loop and checking of all those rows,
but taking your advice and adding some msgbox prompts at certain
points of the code proved that the loop was fine. It was the code
below which caused the problem. if no data was copied into the
workaid workhseet then the code had most of the empty sheet checked
for the values below.

I've fixed this by adding an if to check if "C4" holds a value and if
not then exit the sub at that point.

Again, thanks for your help.
kindest regards,
Matt



Range("C4").End(xlToRight).End(xlDown).Select
Range("C4", ActiveCell).Select

For Each c In Selection
If c.Value = "PM" Then
c.Interior.ColorIndex = Range("C1").Interior.ColorIndex
ElseIf c.Value = "XD" Then
c.Interior.ColorIndex = Range("G1").Interior.ColorIndex
ElseIf c.Value = "MHE" Then
c.Interior.ColorIndex = Range("L1").Interior.ColorIndex
ElseIf c.Value = "MR" Then
c.Interior.ColorIndex = Range("P1").Interior.ColorIndex
ElseIf c.Value = "" Then
c.Interior.ColorIndex = 2
Else: c.Interior.ColorIndex = Range("T1").Interior.ColorIndex
End If

Next c
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro hangs when run from a command button Nigel Excel Programming 11 March 4th 08 08:54 PM
Stop a Macro if no Data found tedd13 Excel Programming 1 November 8th 06 04:05 PM
Macro Hangs GregR Excel Programming 0 March 27th 06 10:40 PM
Macro hangs my excel (not responding) Jeff Excel Programming 3 September 9th 05 12:41 AM


All times are GMT +1. The time now is 04:23 AM.

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"