View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
R. Choate R. Choate is offline
external usenet poster
 
Posts: 106
Default For..Next loop error

How stupid of me not to spot that. When I saw your reply I just popped myself on the forehead. How obvious could it be? Props to you
for spotting the column limit instead of just telling the guy a quicker way to find the blanks like some morons (me) did.

You are a sharp guy and always give good help in these forums.

Richard
--
RMC,CPA


"Don Guillett" wrote in message ...
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