Thread
:
For..Next loop error
View Single Post
#
11
Posted to microsoft.public.excel.programming
R. Choate
external usenet poster
Posts: 106
For..Next loop error
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
Reply With Quote
R. Choate
View Public Profile
Find all posts by R. Choate