Hi all. I'm trying to rearrange the order of the words randomly within a cell. I'm getting a type mismatch error. Here's what I've got so far:
The ShuffleArray function is here: http://www.cpearson.com/excel/ShuffleArray.aspxSub Scramble() Dim sentenceNew As String Dim x As Variant x = Split(ActiveCell.Text, " ") x = ShuffleArray(x) sentenceNew = Join(x, " ") ActiveCell.Offset(1, 1) = sentenceNew End Sub
If I comment out the ShuffleArray line, everything else works fine. What am I doing wrong?
Last edited by synkarius; 02-04-2011 at 07:11 AM. Reason: solved
Hi,
Change the ShuffleArray function signature to this:
You will get an error if the activecell is empty so you should add a check for that too.Function ShuffleArray(InArray As Variant) As Variant()
So. Fast.
Thank you!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks