Thread
:
Simple Code but slow
View Single Post
#
10
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
Simple Code but slow
Try it this way
=======
Option Explicit
Sub counterif()
Dim ms As Range
Dim i As Long
Dim count As Long
Dim x As Integer
Set ms = Selection
x = ms.Rows.count
For i = 2 To ms.Rows.count
Cells(i, Selection.Column) = "MUSA_" & _
Format(i, Application.Rept("0", Len(x)))
Next i
End Sub
========
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"dan dungan" wrote in message
...
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
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett