PC Review


Reply
Thread Tools Rate Thread

2 columns processing

 
 
rodchar
Guest
Posts: n/a
 
      19th Nov 2008
hey all,
i have 2 columns
categories and products

home,furniture
home,household
car,fuel
car,service

is there a way to put above in following format in a new column?

home
furniture
household
car
fuel
service

thanks,
rodchar
 
Reply With Quote
 
 
 
 
Vijay Chary
Guest
Posts: n/a
 
      25th Nov 2008
Hi !! I can give you the algorithm. I'm sure you'll be able to write the
macro.

a) Set up a 1-dim array that is large enough to hold all the
categories.

b) Set up a For...Next loop to move the cursor down the
categories column starting from the first data element (just below the header)

c)If the activecell.value is not found in the array 1.make it
the next element in the array. 2.Enter this value in a third column. 3.
Scan the Products column with an inner (Nested) For...Next, and enter the
products associated with this category below it.

You will have to work out the details of the macro very
carefully. But it will work.

I hope this will help your








"rodchar" wrote:

> hey all,
> i have 2 columns
> categories and products
>
> home,furniture
> home,household
> car,fuel
> car,service
>
> is there a way to put above in following format in a new column?
>
> home
> furniture
> household
> car
> fuel
> service
>
> thanks,
> rodchar

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Nov 2008
This puts the output in a new column on a new worksheet:

Option Explicit
Sub testme01()

Dim wks As Worksheet
Dim RptWks As Worksheet
Dim iRow As Long
Dim oRow As Long

Set wks = Worksheets("Sheet1")
Set RptWks = Worksheets.Add

With wks
RptWks.Cells(1, "A").Value = .Cells(1, "A").Value
RptWks.Cells(2, "A").Value = .Cells(1, "B").Value
oRow = 2
For iRow = 2 To .Cells(.Rows.Count, "A").End(xlUp).Row
If .Cells(iRow, "A").Value <> .Cells(iRow - 1, "A").Value Then
'add the group indicator
oRow = oRow + 1
RptWks.Cells(oRow, "A").Value = .Cells(iRow, "A")
End If
oRow = oRow + 1
RptWks.Cells(oRow, "A").Value = .Cells(iRow, "B").Value
Next iRow
End With

End Sub

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

rodchar wrote:
>
> hey all,
> i have 2 columns
> categories and products
>
> home,furniture
> home,household
> car,fuel
> car,service
>
> is there a way to put above in following format in a new column?
>
> home
> furniture
> household
> car
> fuel
> service
>
> thanks,
> rodchar


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable Button During Processing & Re-Enable After Processing? Donald A. Fisher Microsoft VB .NET 4 15th Dec 2007 05:08 AM
Adding & Processing Columns =?Utf-8?B?UmF5IFMu?= Microsoft Excel Programming 3 29th Jan 2007 05:58 PM
Why does adding columns slow down processing speed? =?Utf-8?B?Q2hlZXItUGhpbC1seQ==?= Microsoft Excel Programming 5 12th Oct 2006 08:47 AM
VBA Textrange Processing: Need help in processing multiple ranges david.f.jenkins@usa.net Microsoft Powerpoint 9 10th May 2005 12:43 AM
Xcel or Access sort columns of names so that I remove the intersect between 2 columns from one of the columns? William.R.Reisen Microsoft Access External Data 2 20th Dec 2003 02:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:58 PM.