Hi, everybody
I obtained the foll. code from a book by a well-known Excel MVP and author.
So, I found it a bit strange why it does not work.
I copied the code from both its web-site and from the book.
The macro is supposed to perform Text to Columns on multiple columns (which cannot be done using Excel menu).
I found Step 5 a bit strange, but the author explains:
"You then simply reset the cell to its own value. This removes any formatting mismatch"
Can anybody spot if there is anything wrong with the code?
Thanks
Leon
I obtained the foll. code from a book by a well-known Excel MVP and author.
So, I found it a bit strange why it does not work.
I copied the code from both its web-site and from the book.
Code:
Sub Macro47()
[I]'Step 1: Declare your variables[/I]
Dim MyRange As Range
Dim MyCell As Range
[I] 'Step 2: Save the Workbook before changing cells?[/I]
Select Case MsgBox("Can't Undo this action. " & _
"Save Workbook First?", vbYesNoCancel)
Case Is = vbYes
ThisWorkbook.Save
Case Is = vbCancel
Exit Sub
End Select
[I]'Step 3: Define the target Range.[/I]
Set MyRange = Selection
[I]'Step 4: Start looping through the range.[/I]
For Each MyCell In MyRange
[I]'Step 5: Reset the cell value.[/I]
If Not IsEmpty(MyCell) Then
MyCell.Value = MyCell.Value [B]'// ?????????[/B]
End If
[I]'Step 6: Get the next cell in the range[/I]
Next MyCell
End Sub
The macro is supposed to perform Text to Columns on multiple columns (which cannot be done using Excel menu).
I found Step 5 a bit strange, but the author explains:
"You then simply reset the cell to its own value. This removes any formatting mismatch"
Can anybody spot if there is anything wrong with the code?
Thanks
Leon