View Single Post
 
Old 11-15-2013, 11:21 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Add a new worksheet (Sheet2) to your workbook, then run the following macro.
Code:
Sub MakeRecords()
Dim i As Long, j As Long, LRow As Long, LCol As Long, wkSht As Worksheet
With ThisWorkbook
  Set wkSht = .Sheets("Sheet2")
  With wkSht
  .Cells(1, 1).Value = "CustId"
  .Cells(1, 2).Value = "ItemId"
  .Cells(1, 3).Value = "Price"
  End With
  With .Sheets("Sheet1")
    LRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
    LCol = .Cells.SpecialCells(xlCellTypeLastCell).Column
    For i = 2 To LRow
      For j = 2 To LCol
        wkSht.Cells((i - 2) * (LCol - 1) + j, 1).Value = .Cells(i, 1).Value
        wkSht.Cells((i - 2) * (LCol - 1) + j, 2).Value = .Cells(1, j).Value
        wkSht.Cells((i - 2) * (LCol - 1) + j, 3).Value = .Cells(i, j).Value
      Next
    Next
  End With
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote