Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function to split a string into multiple characters

Tags:

excel

vba

I want to create a custom function that takes the selected parameter and splits its content on different cells.

example :

A1=ABCDE

becomes

B1=A, C1=B, D1=C, E1=D, F1=E

so this is what I tried :

Function SplitWord(Word)
NbCar = Len(Word) // get the number of cardinals of the text
SplitWord = Left(Word, 1) // put the first letter in the cell that called the function
t = NbCar - 1
For i = 1 To t
ActiveCell.Offset(0, i) = Right(Left(Word, i), 1)
Next
End Function
like image 972
user3288319 Avatar asked Jun 16 '26 14:06

user3288319


1 Answers

  1. Enter the contents to split in cell A1.
  2. Paste this in cell B1: =MID($A$1,COLUMN()-COLUMN($B$1)+1,1)
  3. Drag to the right
like image 193
rbhattad Avatar answered Jun 19 '26 07:06

rbhattad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!