View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Increment Alpha Character

Dan,

If you have a counter, then it may be easier if you use a function like
this:

Dim myName As String

'For Counter Values of 0 To 456975
myName = FileName(Counter)

Function FileName(inVal As Double) As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer

i = (inVal Mod 26) + 1
j = Int((inVal Mod 676) / 26) + 1
k = Int((inVal Mod 17576) / 676) + 1
l = Int((inVal Mod 456976) / 17576) + 1

FileName = Chr(l + 64) & _
Chr(k + 64) & _
Chr(j + 64) & _
Chr(i + 64)

End Function

HTH,
Bernie
MS Excel MVP

"Dan" wrote in message
...
All,

I have a macro which sends data out to a .csv file. My
problem is that I need each line
of the .csv file to have a unique four digit alpha
character starting with AAAA and working all the way to
ZZZZ. I have no clue how to do this.