Related:
- Last word of phrase becomes first word
- Ms word pdf extension - Download - Other
- Ms word mod apk for pc - Download - Word processors
- Full screen word - Guide
- Free word processor - Guide
- Word a5 formaat - Guide
5 responses
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
2 Oct 2010 à 22:54
2 Oct 2010 à 22:54
there are many ways to do it.. run this macro. the data will be like this with a heading in A1
heading
I need Help
I used a Macro
Please help me
the macro is
heading
I need Help
I used a Macro
Please help me
the macro is
Sub test()
Dim j As Long, x As String, k As Long
Dim r As Range, c As Range
Columns("B:B").Delete
Set r = Range(Range("A2"), Range("A2").End(xlDown))
For Each c In r
j = Len(c)
For k = j To 1 Step -1
'msgbox Mid(c, k, 1)
If Mid(c, k, 1) = " " Then GoTo line1
Next k
line1:
x = Right(c, Len(c) - k)
'msgbox x
x = x & " " & Mid(c, 1, k - 1)
'msgbox x
Cells(Rows.Count, "B").End(xlUp).Offset(1, 0) = x
Next c
End Sub
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
3 Oct 2010 à 21:41
3 Oct 2010 à 21:41
see whether this modified macro will work?
Sub test()
Dim j As Long, x As String, k As Long
Dim r As Range, c As Range
Columns("B:B").Delete
On Error GoTo line2
Set r = Range(Range("A2"), Range("A2").End(xlDown))
For Each c In r
j = Len(c)
For k = j To 1 Step -1
'msgbox Mid(c, k, 1)
If Mid(c, k, 1) = " " Then GoTo line1
Next k
line1:
x = Right(c, Len(c) - k)
'msgbox x
x = x & " " & Mid(c, 1, k - 1)
'msgbox x
Cells(Rows.Count, "B").End(xlUp).Offset(1, 0) = x
GoTo nextc
line2:
c.Offset(0, 1) = c
nextc:
Next c
End Sub
I'm still getting the same error messege. Could this be because some of the cells that contain one word also contain hyphens? For example a cell contains the word ACP-CE and thats where the macro stops running and returns the error message - although, now all other one word cells ran with this modified macro.
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
4 Oct 2010 à 21:00
4 Oct 2010 à 21:00
inadvertently you might have added a space at the end or some other mistake;. You CLEAR(NOT MERELY DELETE)-EDIT-CLEARALL of the one word cells.
however I am sending my sample file which you can download from the following web page
http://www.speedyshare.com/files/24550414/jeni_101004.xls
the macro is already in the vb editor of this file.you run the macro and see.
however I am sending my sample file which you can download from the following web page
http://www.speedyshare.com/files/24550414/jeni_101004.xls
the macro is already in the vb editor of this file.you run the macro and see.
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
7 Oct 2010 à 06:08
7 Oct 2010 à 06:08
see whether this modified macro helps
Sub test()
Dim j As Long, x As String, k As Long
Dim r As Range, c As Range
Columns("B:B").Delete
On Error GoTo line2
Set r = Range(Range("A2"), Range("A2").End(xlDown))
For Each c In r
If InStr(c, " ") = 0 Then GoTo line2
j = Len(c)
For k = j To 1 Step -1
'MsgBox Mid(c, k, 1)
If Mid(c, k, 1) = " " Then GoTo line1
Next k
line1:
x = Right(c, Len(c) - k)
'MsgBox x
x = x & " " & Mid(c, 1, k - 1)
'MsgBox x
c.Offset(0, 1) = x
GoTo nextc
line2:
c.Offset(0, 1) = c
nextc:
Next c
End Sub
3 Oct 2010 à 13:22
Thanks again!!