|
-
Jul 6th, 2006, 08:57 AM
#1
Thread Starter
New Member
Excel freezes when running code
I have written code for a macro, the first part of which looks at the whole worksheet (which has over 60 000 entries), prompts the user to enter a specific country name and then copies all the entries for that country in question into a separate worksheet. Here is the relevant part of that code:
Country = InputBox("Enter a country name")
NoClients = Application.WorksheetFunction.CountIf(Range("A:A"), "<>") - 1
For i = NoClients To 0 Step -1
If Cells(i + RowOffset, ColumnOffset) = Country Then
Rows(i + RowOffset).EntireRow.Copy
Worksheets("Country").Activate
Excel.Range("A2").Insert Shift:=xlDown
Worksheets("Sheet1").Activate
End If
Next i
Now the code works fine, except for when I enter Japan or USA, Excel freezes. Both have the highest number of entries in my spreadsheet. China has about 4,500 it works fine, USA has 6,500 and japan even more. I am turning screen updating off and formula calculation to manual. I really am not sure why this is occurring, am I trying to push my PC beyond its capabilities, or is there something wrong with the code?
Many thanks to anyone who can offer any advice.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|