-
Solved: VBA code launching problem
Hi!
Earilier times I used to do some programming in basic and in pascal. Now time has passed and it is needed to write a little program.
Examining my knowledg and consulting with vba literature I wrote a test program but someway it doesnt launch, No error massages no sign of launched program on my excel sheet.
I have allowed all macroses to be used in excel. But I am out of knowledge to act on. This is just 1 purposeless progrem about to write numbers from 1 to 100 by dioganal on screen
[VBA]Sub mingiasi()
Dim i As Integer
i = 0
Do While i = 100
i = i + 1
Range(i, i).Value = i
Loop
End Sub
[/VBA]
I would preciate help and would be very greatful!
Suddenflash
-
Hi. Try this way.
[vba]Sub mingiasi()
Dim i As Integer
i = 0
Do While i < 100
i = i + 1
Cells(i, i).Value = i
Loop
End Sub
[/vba]
-
-
Welcome to the forum. Couple of suggestions
[VBA]
'good idea to include since it forces all variable to be declared
Option Explicit
Sub mingiasi()
'VBA uses Long now
Dim i As Long
'speeds macro by avoiding screen updating
Application.ScreenUpdating = False
'nothing wrong with a Do, but For/Next is useful also
For i = 1 To 100
'This will always refer to the active sheet
' which you might not want
' Cells(i, i).Value = i
'This will refer to Sheet1, regardless of which sheet is active
Worksheets("Sheet1").Cells(i, i).Value = i
Next i
Application.ScreenUpdating = True
End Sub
[/VBA]
Paul
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules