Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Increment Alpha Character

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Increment Alpha Character

Hi Dan,

Dan wrote:
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.


Probably not the most efficient way, but this method should work to generate
the strings from AAAA through ZZZZ:

Sub test()
Dim anBase26(1 To 4) As Integer

anBase26(1) = 0
anBase26(2) = 0
anBase26(3) = 0
anBase26(4) = 0

Do While anBase26(1) <= 25
Debug.Print Chr$(anBase26(1) + 65) & _
Chr$(anBase26(2) + 65) & _
Chr$(anBase26(3) + 65) & _
Chr$(anBase26(4) + 65)
If anBase26(4) < 25 Then
anBase26(4) = anBase26(4) + 1
Else
anBase26(4) = 0
If anBase26(3) < 25 Then
anBase26(3) = anBase26(3) + 1
Else
anBase26(3) = 0
If anBase26(2) < 25 Then
anBase26(2) = anBase26(2) + 1
Else
anBase26(2) = 0
anBase26(1) = anBase26(1) + 1
End If
End If
End If
Loop
End Sub


--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Increment Alpha Character

Dan,

You can create a string that you can use in your code, as below:

HTH,
Bernie
MS Excel MVP

Sub TryNow()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim myName As String

For i = 1 To 26
For j = 1 To 26
For k = 1 To 26
For l = 1 To 26
myName = Chr(i + 64) & _
Chr(j + 64) & _
Chr(k + 64) & _
Chr(l + 64)
'Then use myName in your code
MsgBox myName
Next l
Next k
Next j
Next i
End Sub


"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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
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.



  #5   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Increment Alpha Character


They worked.

Thank You for responding.

-----Original 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.

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
if alpha character samuel Excel Discussion (Misc queries) 4 December 17th 08 03:22 AM
Prevent alpha character in numeric cell Brazil Excel Discussion (Misc queries) 2 July 21st 08 09:28 PM
PICTURE RECOGNITION AS A ALPHA-NUMERIC CHARACTER Greg Wilson Excel Worksheet Functions 0 March 28th 07 12:15 AM
Parsing a alpha character out of a cell Lram Excel Worksheet Functions 7 October 17th 05 10:56 PM
Numerical grade to Alpha character capecrusader Excel Discussion (Misc queries) 6 August 20th 05 02:02 PM


All times are GMT +1. The time now is 10:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"