Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Transfer to adjacent columns

Hi

In column A I have a long list that was originally in 4 columns and without
separators for the old columns, ie Basingstoke & Deane £644 £1,140 +77%
The last 3 are all in the same format but the names vary in size.

Is it possible to write a macro to transfer the % to col 4, the 2nd £ amount
to col 3, the 1st £ amount to col 2 and leave the names in col A?

--
TIA
Tim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Transfer to adjacent columns

Assumes xl2000 or later

Sub AdjustData()
Dim cell as Range, v as Variant, ipos as long
for each cell in Range(Cells(1,1),Cells(1,1).End(xldown))
v = Split(Application.Trim(cell)," ")
cell.offset(0,1) = v(ubound(v)-2)
cell.offset(0,2) = v(ubound(v)-1)
cell.offset(0,3) = v(ubound(v))
ipos = instr(1,cell.value,"£",vbTextCompare)
cell.value = Trim(Left(cell.value,ipos-1))
Next
End Sub

Test it on a copy of your data

--
Regards,
Tom Ogilvy


"Tim" wrote in message
...
Hi

In column A I have a long list that was originally in 4 columns and

without
separators for the old columns, ie Basingstoke & Deane £644 £1,140 +77%
The last 3 are all in the same format but the names vary in size.

Is it possible to write a macro to transfer the % to col 4, the 2nd £

amount
to col 3, the 1st £ amount to col 2 and leave the names in col A?

--
TIA
Tim



  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Transfer to adjacent columns

Thanks Tom - it worked fine
--
Tim


"Tom Ogilvy" wrote:

Assumes xl2000 or later

Sub AdjustData()
Dim cell as Range, v as Variant, ipos as long
for each cell in Range(Cells(1,1),Cells(1,1).End(xldown))
v = Split(Application.Trim(cell)," ")
cell.offset(0,1) = v(ubound(v)-2)
cell.offset(0,2) = v(ubound(v)-1)
cell.offset(0,3) = v(ubound(v))
ipos = instr(1,cell.value,"£",vbTextCompare)
cell.value = Trim(Left(cell.value,ipos-1))
Next
End Sub

Test it on a copy of your data

--
Regards,
Tom Ogilvy


"Tim" wrote in message
...
Hi

In column A I have a long list that was originally in 4 columns and

without
separators for the old columns, ie Basingstoke & Deane £644 £1,140 +77%
The last 3 are all in the same format but the names vary in size.

Is it possible to write a macro to transfer the % to col 4, the 2nd £

amount
to col 3, the 1st £ amount to col 2 and leave the names in col A?

--
TIA
Tim




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add cells on two adjacent rows but non-adjacent columns Eve Excel Worksheet Functions 14 October 20th 09 02:32 AM
AUTOFILTER-2 non-adjacent columns GaryW New Users to Excel 3 May 21st 08 10:54 PM
How to keep data in two adjacent columns together Frank Beltre New Users to Excel 1 May 23rd 07 09:52 PM
combining adjacent columns rooniwife Excel Discussion (Misc queries) 3 July 6th 05 02:18 AM
Printing non-adjacent columns Ann Shaw Excel Discussion (Misc queries) 2 February 16th 05 04:45 PM


All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"