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

I have a qorksheet that has with an unique value for each row under column A
and multiple columns/range, B2 - H40 that can have a value. I need to figure
out how to reflect the column heading, B1 - H1 for each cell populated within
the row/range. Ultimately, I would like a list on separate worksheet of the
row and column relationship.

Any ideas?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default Searching across columns

Your requirement is not clear (at least to me).

Can you provide more details with some examples of the data you have?

"Pablo" wrote:

I have a qorksheet that has with an unique value for each row under column A
and multiple columns/range, B2 - H40 that can have a value. I need to figure
out how to reflect the column heading, B1 - H1 for each cell populated within
the row/range. Ultimately, I would like a list on separate worksheet of the
row and column relationship.

Any ideas?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Searching across columns

Lets say in column A is my unique records beginning at A2 (123,456,789,...).
Columns B through H are categories (Animals, Cars, Sports,... Money) that my
records could be associated with. Record 123 may be associated with Cars and
Money by using an "X" in the cells (C2 and H2). Record 456 is associated with
Animals, Cars, and Sports (B3, C3, and D3).

The result I am looking for would be on worksheet 2
123 | Cars
123 | Money
456 | Animals
456 | Cars
456 | Sports



"Sheeloo" wrote:

Your requirement is not clear (at least to me).

Can you provide more details with some examples of the data you have?

"Pablo" wrote:

I have a qorksheet that has with an unique value for each row under column A
and multiple columns/range, B2 - H40 that can have a value. I need to figure
out how to reflect the column heading, B1 - H1 for each cell populated within
the row/range. Ultimately, I would like a list on separate worksheet of the
row and column relationship.

Any ideas?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default Searching across columns

Understood... I will write a macro and share with you later today...

"Pablo" wrote:

Lets say in column A is my unique records beginning at A2 (123,456,789,...).
Columns B through H are categories (Animals, Cars, Sports,... Money) that my
records could be associated with. Record 123 may be associated with Cars and
Money by using an "X" in the cells (C2 and H2). Record 456 is associated with
Animals, Cars, and Sports (B3, C3, and D3).

The result I am looking for would be on worksheet 2
123 | Cars
123 | Money
456 | Animals
456 | Cars
456 | Sports



"Sheeloo" wrote:

Your requirement is not clear (at least to me).

Can you provide more details with some examples of the data you have?

"Pablo" wrote:

I have a qorksheet that has with an unique value for each row under column A
and multiple columns/range, B2 - H40 that can have a value. I need to figure
out how to reflect the column heading, B1 - H1 for each cell populated within
the row/range. Ultimately, I would like a list on separate worksheet of the
row and column relationship.

Any ideas?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,805
Default Searching across columns

Use this macro
See comments for understanding

Sub copyMacro()

Dim lastRow As Long
Dim i, j, k As Long

'Change Long to String in the statement below if Ids are not pure numbers
Dim Id As Long

Dim lastCol As Integer
' H is column 8, change it accordingly if your
' last column is different
lastCol = 8

'Find last row on Sheet1
With Worksheets("Sheet1")
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

'Start at row 2 on sheet2
j = 2

'Loop through all rows in Sheet1
For i = 2 To lastRow
Id = Worksheets("Sheet1").Cells(i, 1).Value

'Loop through all columns in Sheet1 looking for X (x won't match)
For k = 2 To lastCol
'If all columns are blank for one id then
'that id won't be written to sheet2
If Worksheets("Sheet1").Cells(i, k).Value = "X" Then
'write to Sheet2
Worksheets("Sheet2").Cells(j, 1).Value = Id
Worksheets("Sheet2").Cells(j, 2).Value = _
Worksheets("Sheet1").Cells(1, k).Value
'increment row number on Sheet2
j = j + 1
End If
Next k

Next i

End Sub


"Sheeloo" wrote:

Understood... I will write a macro and share with you later today...

"Pablo" wrote:

Lets say in column A is my unique records beginning at A2 (123,456,789,...).
Columns B through H are categories (Animals, Cars, Sports,... Money) that my
records could be associated with. Record 123 may be associated with Cars and
Money by using an "X" in the cells (C2 and H2). Record 456 is associated with
Animals, Cars, and Sports (B3, C3, and D3).

The result I am looking for would be on worksheet 2
123 | Cars
123 | Money
456 | Animals
456 | Cars
456 | Sports



"Sheeloo" wrote:

Your requirement is not clear (at least to me).

Can you provide more details with some examples of the data you have?

"Pablo" wrote:

I have a qorksheet that has with an unique value for each row under column A
and multiple columns/range, B2 - H40 that can have a value. I need to figure
out how to reflect the column heading, B1 - H1 for each cell populated within
the row/range. Ultimately, I would like a list on separate worksheet of the
row and column relationship.

Any ideas?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Searching across columns

Sheelo - This works perfectly. Thanks

"Sheeloo" wrote:

Use this macro
See comments for understanding

Sub copyMacro()

Dim lastRow As Long
Dim i, j, k As Long

'Change Long to String in the statement below if Ids are not pure numbers
Dim Id As Long

Dim lastCol As Integer
' H is column 8, change it accordingly if your
' last column is different
lastCol = 8

'Find last row on Sheet1
With Worksheets("Sheet1")
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

'Start at row 2 on sheet2
j = 2

'Loop through all rows in Sheet1
For i = 2 To lastRow
Id = Worksheets("Sheet1").Cells(i, 1).Value

'Loop through all columns in Sheet1 looking for X (x won't match)
For k = 2 To lastCol
'If all columns are blank for one id then
'that id won't be written to sheet2
If Worksheets("Sheet1").Cells(i, k).Value = "X" Then
'write to Sheet2
Worksheets("Sheet2").Cells(j, 1).Value = Id
Worksheets("Sheet2").Cells(j, 2).Value = _
Worksheets("Sheet1").Cells(1, k).Value
'increment row number on Sheet2
j = j + 1
End If
Next k

Next i

End Sub


"Sheeloo" wrote:

Understood... I will write a macro and share with you later today...

"Pablo" wrote:

Lets say in column A is my unique records beginning at A2 (123,456,789,...).
Columns B through H are categories (Animals, Cars, Sports,... Money) that my
records could be associated with. Record 123 may be associated with Cars and
Money by using an "X" in the cells (C2 and H2). Record 456 is associated with
Animals, Cars, and Sports (B3, C3, and D3).

The result I am looking for would be on worksheet 2
123 | Cars
123 | Money
456 | Animals
456 | Cars
456 | Sports



"Sheeloo" wrote:

Your requirement is not clear (at least to me).

Can you provide more details with some examples of the data you have?

"Pablo" wrote:

I have a qorksheet that has with an unique value for each row under column A
and multiple columns/range, B2 - H40 that can have a value. I need to figure
out how to reflect the column heading, B1 - H1 for each cell populated within
the row/range. Ultimately, I would like a list on separate worksheet of the
row and column relationship.

Any ideas?


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
searching columns for the same value Diggs Setting up and Configuration of Excel 1 March 30th 08 01:22 PM
Searching Columns mully Excel Discussion (Misc queries) 2 February 3rd 06 12:50 PM
searching in several columns [email protected] Excel Programming 5 October 20th 05 05:32 PM
Searching Columns Aviator Excel Discussion (Misc queries) 3 January 26th 05 11:13 PM
Searching Columns Pat[_9_] Excel Programming 0 November 24th 03 06:46 PM


All times are GMT +1. The time now is 04:55 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"