Generating a line for each 'x' that appears in that row.

howiechiang

New Member
Joined
Jan 27, 2014
Messages
12
|Category||cat. 1cat. 1|| cat. 2 cat. 2||cat. 3cat. 3||cat. 4|
|Number|| #1 || #2 || #1 || #2 || #1 || #2 || #1 |
|Name|
|Al|xx
|Ben|xx
|Fred|x

<tbody>
</tbody>

<tbody>
</tbody>
I need a chart that will generate a line for each 'x' in a box in that row. That new chart will call out what 'category' and 'number' that 'x' is in.

The solution should come out to this:
NameCategoryNumber
Alcat. 1#2
Alcat. 3#2
Bencat. 1#1
Bencat. 2#2
Fredcat. 4#1

<tbody>
</tbody>
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
There is also a Task Function Column in my 'oTarget' spread sheet. There is only one task function per name, but the output may create more than one line per name due to multiple 'x' marks. Is there a way to create a Task Function column in my output, the multiple rows of the same name are merged.
This is what I have at the moment.
Public Sub RetrieveData()

'Clear current data on List Sheet'
Worksheets("List Sheet1").Activate
Range("A2:F500").Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.ClearContents


'Set Ranges'
Dim oTarget As Range
Dim oXed As Range
Dim oCell As Range
Dim oDest As Range


'Set up target & destination'
Worksheets("Chart Sheet").Activate
Set oDest = ThisWorkbook.Worksheets("List Sheet1").Range("A1")
Set oTarget = ActiveSheet.Range("B5:AR999")


'Select only the cells in B5:AR999 that contain an X'
Set oXed = oTarget.SpecialCells(xlCellTypeConstants)
oDest.Value = "Name"
oDest.Offset(0, 1).Value = "Category"
oDest.Offset(0, 2).Value = "Number"
Set oDest = oDest.Offset(1, 0)


'Transpose the data starting in A2 of Sheet2'
For Each oCell In oXed
oDest.Value = Cells(oCell.Row, 1).Value
oDest.Offset(0, 1).Value = Cells(2, oCell.Column).Value
oDest.Offset(0, 2).Value = Cells(3, oCell.Column).Value
Set oDest = oDest.Offset(1, 0)
Next oCell


'Go to List Sheet'
Worksheets("List Sheet1").Activate


End Sub
 
Upvote 0
Don't worry about that post i made at 2:03pm. I was able to figure it out myself after a little bit of grunt work.
This is actually my first experience working with VBA (and second time working with any sort of programming language), and I'm catching on.
Thank you for your time and effort Gary.
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top