P
peter
Fellow excel programmers
I have the following little program which gives me an error
Sub code(
' code Macr
' Keyboard Shortcut: Ctrl+
For i = 1 To
ActiveCell.FormulaR1C1 = "=CODE(MID(R[-1]C1,LEN(R[-1]C1)-(LEN(R[-1]C1)
i),1))"
ActiveCell.Offset(0, 1).Range("A1".Selec
Next
End Su
The problem is that when I run this code it gives me a "VALUE"
error
The computer claims that the "i" in this part of the cod
(LEN(R[-1]C1)- i),1)) is what causes the value error
I am just teaching VB to myself so I am not that great. The code abov
therefor
might not make much sense. Therefore, let me explain what I wanted t
accomplish
I want the program to start at cell A2, then look at the string in cell A1
the
convert the first character of the string to it's ASCII number, then move ove
to cell B2, repeat the process for the second letter... 5 times. In the end m
output will be 5 cells immediately below the string lined by from A2 to E2
which give me the number values of each of the first five characters of th
string
I hope this is clear
I THOUGHT I could use the counter "i" inside
,"LEN(R[-1]C1)-(LEN(R[-1]C1)- i", to tell the computer which lette
t
look at. This code should give me
i =
len(word) - (len(word) - 1) = first lette
mid(first letter
code(mid(first letter
loop bac
i =
len(word) - (len(word) - 2) = second lette
mid(second letter
code(mid(second letter
loop back...etc 3 more times
however...this is not working..
could someone please explain why and suggest how I could fix this
Please note that since I am not great at programming, the way I make my cod
i
by recording a macro for the first iteration and then surrounding the cod
created by my recording with a for loop and, in this case, replacin
len(word) - (Len(word) - 1 wit
len(word) - (Len(word) -
in order to tell excel to automatically look at the next letter in the word
So, could anyone offer help?
I have the following little program which gives me an error
Sub code(
' code Macr
' Keyboard Shortcut: Ctrl+
For i = 1 To
ActiveCell.FormulaR1C1 = "=CODE(MID(R[-1]C1,LEN(R[-1]C1)-(LEN(R[-1]C1)
i),1))"
ActiveCell.Offset(0, 1).Range("A1".Selec
Next
End Su
The problem is that when I run this code it gives me a "VALUE"
error
The computer claims that the "i" in this part of the cod
(LEN(R[-1]C1)- i),1)) is what causes the value error
I am just teaching VB to myself so I am not that great. The code abov
therefor
might not make much sense. Therefore, let me explain what I wanted t
accomplish
I want the program to start at cell A2, then look at the string in cell A1
the
convert the first character of the string to it's ASCII number, then move ove
to cell B2, repeat the process for the second letter... 5 times. In the end m
output will be 5 cells immediately below the string lined by from A2 to E2
which give me the number values of each of the first five characters of th
string
I hope this is clear
I THOUGHT I could use the counter "i" inside
,"LEN(R[-1]C1)-(LEN(R[-1]C1)- i", to tell the computer which lette
t
look at. This code should give me
i =
len(word) - (len(word) - 1) = first lette
mid(first letter
code(mid(first letter
loop bac
i =
len(word) - (len(word) - 2) = second lette
mid(second letter
code(mid(second letter
loop back...etc 3 more times
however...this is not working..
could someone please explain why and suggest how I could fix this
Please note that since I am not great at programming, the way I make my cod
i
by recording a macro for the first iteration and then surrounding the cod
created by my recording with a for loop and, in this case, replacin
len(word) - (Len(word) - 1 wit
len(word) - (Len(word) -
in order to tell excel to automatically look at the next letter in the word
So, could anyone offer help?