Reputation: 11
I am generating an excel output with a field that has repetitive numbers in each record. The number increments at a change of a value in another field.
Example: Field1 field2 1 A 1 A 2 B 3 D 4 F 4 F 4 F 5 R
I want 1 to represent A, 2 represent B, 3 represent D etc and not have a repeat of numbers.
Upvotes: 0
Views: 155
Reputation: 9290
Your question is not very clear, but here are some suggestions:
[A] [B] 1 =Char(A1 - 64) 2 =Char(A2 - 64) 3 =Char(A3 - 64)
if you have the characters and want to obtain the values you can do the opposite by using the Code function:
[A] [B] =Code(A1) - 64 A =Code(A2) - 64 B =Code(A3) - 64 C
Upvotes: 0
Reputation: 108790
It's a bit hard to interpret your question, but perhaps you want something like this:
Dictionary<string,int> dict=new Dictionary<string,int>();
int counter=1;
int IdOfString(string s)
{
int i;
if(dict.TryGetValue(s,i))
return i;
else
{
i=counter;
counter++;
dict.Add(s,i);
return i;
}
}
It returns a new number for each unique string you pass into IdOfString
Upvotes: 1