Home |
Search |
Today's Posts |
#18
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 28 Sep 2008 01:48:11 -0700, Daniel Thuriaux wrote:
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 Perhaps this will work. Be sure to read the comments within the Sub: =========================================== Option Explicit Sub ChangeOrder() Dim c As Range Dim rg As Range Dim sRes(0 To 2) As String Dim sDesc As String Dim i As Long Set rg = Range("A1:A5000") 'set to range to be processed ' first column only For Each c In rg sRes(0) = Trim(c.Value) 'BRAND sRes(1) = Trim(c.Offset(0, 1).Value) 'Item sRes(2) = Trim(c.Offset(0, 2).Value) 'original 'remove BRAND sRes(2) = Replace(sRes(2), sRes(0), "", 1, 1, vbTextCompare) 'check for duplicate of Item value i = Len(sRes(2)) - Len(Replace(sRes(2), sRes(1), "", , , vbTextCompare)) 'replace "last" item value sRes(2) = Replace(sRes(2), sRes(1), "", 1, i, vbTextCompare) 'column offset set to 3 for debugging. When satisfied, set it to 2 c.Offset(0, 3).Value = Join(sRes) Next c End Sub ==================================== --ron |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding Zeros in front of numbers in cells using Excel 2003 | Excel Programming | |||
HowTo add a period to front of EVERY text cell in a Excel column | Excel Programming | |||
input text at front of field that contains data | Excel Discussion (Misc queries) | |||
Formula for adding a comma in front of text in a cell | Excel Worksheet Functions | |||
How do I Remove bullets from text data in Excel cell with macro? | Excel Programming |