ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For loop with letters (https://www.excelbanter.com/excel-programming/326788-loop-letters.html)

[email protected]

For loop with letters
 
Does anyone know how to make a do loop with letters?

I.E

For (filename = A to Z)
delete filename
End loop

Thanks in advance.


Trevor Shuttleworth

For loop with letters
 
One way:

Dim i As Integer
Dim sFileName As String
For i = 1 To 26
'Debug.Print Chr(i + 64)
sFileName = Chr(i + 64)
Kill sFileName
Next 'i

or just:

For i = 1 To 26
Kill Chr(i + 64)
Next 'i


Regards

Trevor


wrote in message
oups.com...
Does anyone know how to make a do loop with letters?

I.E

For (filename = A to Z)
delete filename
End loop

Thanks in advance.




Dave Peterson[_5_]

For loop with letters
 
One mo

Option Explicit
Sub testme01()
Dim iCtr As Long
For iCtr = Asc("A") To Asc("Z")
MsgBox Chr(iCtr)
'Kill pathname:=Chr(iCtr)
Next iCtr
End Sub



wrote:

Does anyone know how to make a do loop with letters?

I.E

For (filename = A to Z)
delete filename
End loop

Thanks in advance.


--

Dave Peterson


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com