read letters of a surname sequentially

KG Old Wolf

Board Regular
Joined
Sep 20, 2009
Messages
65
This is a perfect use of an array and I am missing something very basic.

I am trying to load a surname variable into an array and then index through each element to inspect and assign a value (part of a SOUNDEX routine). I ReDim the array with the length of the surname but the entire surname loads into the first array element and I can't access a single letter (I get the entire name). Below is a simple code snippet. Suggestions greatly appreciated!


Sub KG()
wrk_string = "Test"
wrk_length = Len(wrk_string)
ReDim ary_last_name(1 To 1)
ary_last_name(1) = wrk_string
ReDim ary_last_name(1 To wrk_length)
MsgBox (ary_last_name(2))

End Sub


 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi

See if this helps:

Code:
Sub SplitWord()
Dim s As String
Dim vLetters() As String
Dim j As Long

s = "Test"
ReDim vLetters(1 To Len(s))

' Load each element of the array with 1 letter of the word
For j = 1 To Len(s)
    vLetters(j) = Mid(s, j, 1)
Next j

MsgBox vLetters(2)
End Sub
 
Upvote 0
PGC...

Thanks, it helps a great deal. I particularly appreciate he speed of your response.


Best regards,
Ken
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top