Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Copy Headings based on Cell Value

I have up to 300 rows of data with 11 columns on sheet "Data Sort 1". Column
A is filled based on some code running. Columns B-K may or may not have data
based on the fact that all of these cells have an IF formula.

What I need the data to do is search for data in the cell of each row. If
there is data, then enter the column heading on a different page ("Data Sort
1b"). The data would look like on the original sheet:

A B C D
E
Op # Op Desc Mech Risk Electr Risk Haz
Risk

10 test 1 elec 1
haz 1
10 test 2 mech 1
haz 2
10 test 3 mech 2 elec 2
10 test 4 elec 3


I need it to look like this on the second sheet in column C starting at row 2:

Electr Risk
Haz Risk
Mech Risk
Haz Risk
Mech Risk
Electr Risk
Electr Risk

Thanks for any help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Copy Headings based on Cell Value

Here is the result I figured out:

Sheets("Data Sort 1b").Activate
With SourceSht
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
SourceRow = 2
DestRow = 2
SourceCol = 3
DestCol = 3
Do While .Range("A" & SourceRow) < ""
For Colcount = 3 To LastCol
If Trim(.Cells(SourceRow, Colcount)) < "" Then
HazardCategory = .Cells("1", Colcount).Value
DestSht.Range("C" & DestRow) = HazardCategory
DestRow = DestRow + 1
End If
Next Colcount
SourceRow = SourceRow + 1
Loop

Application.CutCopyMode = False
End With

"Jeff Gross" wrote:

I have up to 300 rows of data with 11 columns on sheet "Data Sort 1". Column
A is filled based on some code running. Columns B-K may or may not have data
based on the fact that all of these cells have an IF formula.

What I need the data to do is search for data in the cell of each row. If
there is data, then enter the column heading on a different page ("Data Sort
1b"). The data would look like on the original sheet:

A B C D
E
Op # Op Desc Mech Risk Electr Risk Haz
Risk

10 test 1 elec 1
haz 1
10 test 2 mech 1
haz 2
10 test 3 mech 2 elec 2
10 test 4 elec 3


I need it to look like this on the second sheet in column C starting at row 2:

Electr Risk
Haz Risk
Mech Risk
Haz Risk
Mech Risk
Electr Risk
Electr Risk

Thanks for any help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Copy Headings based on Cell Value

pretty good
1.you don't need
Application.CutCopyMode = False
2.ColumnsCount needs the decimal ie .ColumnsCount
3. the sheet doesn't even need to be the active sheet



With Sheets("Data Sort 1b")
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
SourceRow = 2
DestRow = 2
SourceCol = 3
DestCol = 3
Do While .Range("A" & SourceRow) < ""
For Colcount = 3 To LastCol
If Trim(.Cells(SourceRow, Colcount)) < "" Then
DestSht.Cells(DestRow,"C") = .Cells("1", Colcount).Value
DestRow = DestRow + 1
End If
Next Colcount
SourceRow = SourceRow + 1
Loop



"Jeff Gross" wrote in message
...
Here is the result I figured out:

Sheets("Data Sort 1b").Activate
With SourceSht
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
SourceRow = 2
DestRow = 2
SourceCol = 3
DestCol = 3
Do While .Range("A" & SourceRow) < ""
For Colcount = 3 To LastCol
If Trim(.Cells(SourceRow, Colcount)) < "" Then
HazardCategory = .Cells("1", Colcount).Value
DestSht.Range("C" & DestRow) = HazardCategory
DestRow = DestRow + 1
End If
Next Colcount
SourceRow = SourceRow + 1
Loop

Application.CutCopyMode = False
End With

"Jeff Gross" wrote:

I have up to 300 rows of data with 11 columns on sheet "Data Sort 1".
Column
A is filled based on some code running. Columns B-K may or may not have
data
based on the fact that all of these cells have an IF formula.

What I need the data to do is search for data in the cell of each row.
If
there is data, then enter the column heading on a different page ("Data
Sort
1b"). The data would look like on the original sheet:

A B C D
E
Op # Op Desc Mech Risk Electr Risk
Haz
Risk

10 test 1 elec 1
haz 1
10 test 2 mech 1
haz 2
10 test 3 mech 2 elec 2
10 test 4 elec 3


I need it to look like this on the second sheet in column C starting at
row 2:

Electr Risk
Haz Risk
Mech Risk
Haz Risk
Mech Risk
Electr Risk
Electr Risk

Thanks for any help.


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
Lookup in a matrix (with x and y headings) based on value x and y johan Excel Discussion (Misc queries) 2 August 17th 09 08:20 PM
COUNTIFs Based on Field Headings DOUG Excel Discussion (Misc queries) 15 July 25th 09 01:16 AM
Look up based on Column and Row headings AD108 Excel Worksheet Functions 4 August 9th 06 07:42 PM
Change a row of headings based on other selected cells jjh[_2_] Excel Programming 0 July 6th 06 02:39 AM
Summing rows based on column headings DallasLDY Excel Worksheet Functions 1 March 8th 06 09:35 PM


All times are GMT +1. The time now is 01:21 AM.

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"