View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
dan dungan dan dungan is offline
external usenet poster
 
Posts: 411
Default Simple Code but slow

Hi Don,

I'm testing this to better understand how vba works.

When I run this procedure it returns "Variable not defined".

So I added to the procedu

Sub counterif()
Dim ms As Range
Set ms = Selection
Dim i As Integer

For i = 2 To ms.Rows.Count
Cells(i, Selection.Column) = "MUSA_" & _
Format(i, Application.Rept("0", Len(ms.Rows.Count)))
Next i
End Sub

Now when I run it the procedure returns:
Compile error:
Variable required--can't assign to this expression

Format(i, Application.Rept("0", Len(ms.Rows.Count)))

..Count is highlighted.

Dan