Split a string into array and paste into a sheet in Excel VBA

Опубликовано: 13 Октябрь 2024
на канале: EverydayVBA
9,990
71

Grab the Free VBA Quick Reference Guide
https://www.chrisjterrell.com/excel-v...
The Split Function in VBA will split a string into a one-dimensional array. The text will be split based on the Delimiter. It is used to specify where the text should be split. In the code example below the text string is split with a space. Then we use the Ubound of the Array to resize the range to make it the same size and then make the range equal to the oarray.

Code

Sub SplitArray()
cells(1,1) = "How do I split an array"

oarray = Split(Cells(1, 1), " ")

Cells(2, 1).Resize(, UBound(oarray) + 1) = oarray

End Sub