RV,
That macro worked wonders in the sample file, but when administered to the "real" file, things went haywire. I changed a couple cell #'s, but that's it. I can't figure it out.
I think the problem may lie within this string: (I'm not clear as to what the "6" refers to)
'cell in column C of the first empty row is equal the value in the cell whose
'range is row 6 and the current cell in the loop's column
.Range("C" & LR2).Value = Cells(6, c.Column).Value
Sub Verticaldatatosheet2()
Dim c As Range, LR As String, LR2 As String 'declare variables
Sheets(1).Select 'select the first worksheet in the workbook
LR = Sheets(1).Range("A408").End(xlUp).Row 'set LR equal to the last row in column A that contains a value
'loop through cells in the first worksheet in the workbook
'cells H15 through FU and row LR (defined above)
For Each c In Sheets(1).Range("H15:FU" & LR).Cells
If c.Value <> 0 Then 'if the value in the current cell in the loop is not 0 then
With Sheets(2) 'with the second worksheet in the workbook
LR2 = .Range("409").End(xlUp).Row + 1 'set LR2 equal to the first empty row in column B
'cell in column A of the first empty row is equal to the current cell in the loop's value in column C in sheet1
.Range("A" & LR2).Value = Range("C" & c.Row).Value
'cell in column B of the first empty row is equal to cell E3 of sheet1
.Range("B" & LR2).Value = Range("E3").Value
'cell in column C of the first empty row is equal the value in the cell whose
'range is row 6 and the current cell in the loop's column
.Range("C" & LR2).Value = Cells(6, c.Column).Value
'cell in column D of the first empty row is equal to the current cell in the loop's value
.Range("D" & LR2).Value = c.Value
End With
End If
Next c 'move to next cell in the loop
End Sub
Here's how the 2nd sheet looks now:
ID# VENDOR MARKET PRICE
Company ABC, Inc. $1.00
1.000 Company ABC, Inc. $1.00
Company ABC, Inc. $1.00
1.000 Company ABC, Inc. $1.00
Company ABC, Inc. $1.00
1.000 Company ABC, Inc. $1.00
Compared to the correct layout you supplied earlier:
ID# VENDOR MARKET PRICE
1.000 Vendor, Inc. TX, Houston $1.20
1.000 Vendor, Inc. TX, Houston $1.20
1.000 Vendor, Inc. UT, Ogden $1.20
1.000 Vendor, Inc. AZ, Phoenix $1.20
1.000 Vendor, Inc. CA, San Diego $1.20
2.000 Vendor, Inc. TX, Houston $2.60
2.000 Vendor, Inc. UT, Ogden $2.30
2.000 Vendor, Inc. AZ, Phoenix $2.30
2.000 Vendor, Inc. CA, San Diego $2.30
3.000 Vendor, Inc. TX, Houston $10.25
3.000 Vendor, Inc. UT, Ogden $10.30
3.000 Vendor, Inc. AZ, Phoenix $9.98
3.000 Vendor, Inc. CA, San Diego $12.00
Bookmarks