Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default 2 columns processing

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default 2 columns processing

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 2 columns processing

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 he
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
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
excel processing Wendy Elizabeth Excel Worksheet Functions 1 June 18th 07 05:17 PM
Adding & Processing Columns Ray S. Excel Programming 3 January 29th 07 05:58 PM
Why does adding columns slow down processing speed? Cheer-Phil-ly Excel Programming 5 October 12th 06 08:47 AM
Error processing Jerry[_20_] Excel Programming 3 January 20th 06 06:31 PM
processing message hans Excel Programming 5 April 26th 04 03:13 PM


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

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

About Us

"It's about Microsoft Excel"