LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Loop too slow deleteing xltoleft

Good afternoon,

I am re-creating a SAP profit centre hierarchy in excel.
Previous macros that i use will put data in columns A to column G.
This will give me a spreadsheet that looks like this:
Assume y's and x's are 10 digit number/letters

A B C D E F G
yyyyy xxxxx xxxxx xxxxx xxxxx xxxxx
yyyyy xxxxx xxxxx xxxxx xxxxx
yyyyy xxxxx
yyyyy xxxxx xxxxx
yyyyy xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
yyyyy xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
yyyyy xxxxx xxxxx xxxxx

The macro, attached below, I have written checks to see if there is
anything in column A and if nothing in col B then delete left till
column B has a value. Then move onto the next row.
The problem is that it is too slow, over 9 mins, for it too process
anything between 4000 and 25000 rows.

Can you please help and include comments so that I can learn.

Ta,

Marc

Sub parent_alignment()

Application.StatusBar = "SAP hierarchy alignment"

Application.ScreenUpdating = False
On Error Resume Next
Dim rngcell As Range

Sheets("SAP").Activate
Range("A2:A25000").Activate
For Each rngcell In Selection
If rngcell < blank And rngcell.Offset(0, 1) = blank Then

Do Until rngcell.Offset(0, 1) < blank
rngcell.Offset(0, 1).Delete Shift:=xlToLeft

Loop

End If

Next rngcell
Application.StatusBar = "All done"
Application.ScreenUpdating = True

End Sub
 
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
Slow VBA code....Hide/Unhide Loop Tami Excel Worksheet Functions 2 August 4th 09 01:53 AM
VBA loop slow if another workbook open George[_8_] Excel Discussion (Misc queries) 3 September 29th 08 01:30 PM
deleteing objects Debi Excel Discussion (Misc queries) 2 January 16th 07 06:25 PM
Deleteing koba Excel Discussion (Misc queries) 2 November 25th 05 04:11 AM
slow program in a loop chris Excel Programming 4 October 2nd 03 07:58 AM


All times are GMT +1. The time now is 03:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"