View Single Post
  #30   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Changing text order into a cell

Sub RevWords()
Dim lastRow As Long
Dim i As Long
Dim s As String
Dim sCol As String
Dim arrSplit
Dim rng As Range, cel As Range

sCol = "C" ' << Change to suit

With ActiveSheet
s = .Range(sCol & .Rows.Count).Address
lastRow = .Range(sCol & .Rows.Count).End(xlUp).Row
End With

Set rng = Range(sCol & "1:" & sCol & lastRow)

For Each cel In rng
With cel
If InStr(2, .Value, " ") Then
arrSplit = Split(.Value, " ")

s = ""
For i = UBound(arrSplit) To 0 Step -1
s = s & arrSplit(i)
If i 0 Then s = s & " "
Next

.Value = s
End If
End With
Next

End Sub

Regards,
Peter T

<Daniel Thuriaux wrote in message
...
Hello,

Can somebody help me with the following?

I'm using Excel (office 2007)

I have to manage pricelists containing each abt.5000 rows
Unfortunately, the information in the cells of the Column C appears in the
wrong order

for example, the existing format is:

A B C
BRAND Item BRAND Description ITEM

I would like to invert the content of the cells in the column C into:

A B C
BRAND Item BRAND ITEM Description

I already did a try with a macro clearing partly the text equal to the
text found in the colomn A and B, but I haven’t found a way to insert it
back into the cells of the column C in the right order
Is there a possibility to have it done with a macro?

Thanks in advance for your help