LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default For..Next loop error

I suspect you are looping all the way to the bottom of the sheet and thus
that is why it is so slow. Looping from the highest numbered row back to
row 2 will solve that problem although it isn't clear exactly what you are
doing besides deleting blanks.

--
Regards,
Tom Ogilvy

"Ian_Limbo" wrote in message
...
Bingo! Thanks very much! It works now - if a little slow, but i need to

code
up the copy and pasteing (its manual at the moment), before i transfer in

the
smarter code. This is my first dabble at sorting out repititive tasks

that i
have to do.

Many thanks again

Ian

"R. Choate" wrote:

because your loop is crawling to the right with the line

cellcontent = Sheets("Selection List").Cells(1, i)

Once i gets bigger than 255 it is going to throw an error because

anything larger than Cells(1,256) doesn't exist
--
RMC,CPA


"Ian_Limbo" wrote in message

...
If i am deleting rows in a column, which is what appears to be

happening,
where does the column limit problem come in?

"Don Guillett" wrote:

Maybe because there are no more columns after 255???

--
Don Guillett
SalesAid Software

"Ian_Limbo" wrote in message
...
I am attempting to compress a column of data by deleting blank cells

that
has
lots of gaps in it. It errors at no. 256 on the for loop.

The code i am using is:

Sub CommandButton1_Click()
Dim i As Double
Dim cellcontent As String
Range("A2").Select
MsgBox "Cell selected"
For i = 2 To 2150 Step 1
cellcontent = Sheets("Selection List").Cells(1, i)
Do While ActiveCell.Value = ""
Selection.Delete
Loop
ActiveCell.Offset(1, 0).Select
Next i
MsgBox "Selection list complete"
End Sub

All help is gratefully received (this is my first attempt at VBA)

Ian








 
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
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Error in loop Daniel Bonallack[_2_] Excel Programming 2 November 19th 03 07:10 PM
loop error Sam Excel Programming 0 September 25th 03 02:32 PM
loop error Sam Excel Programming 1 September 18th 03 03:09 PM
loop error Sam Excel Programming 0 September 18th 03 02:19 PM


All times are GMT +1. The time now is 02:11 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"