Wednesday, January 21, 2009

convert sparce matrix to lookup in Excel

Sub EEIC_PEC_Conversion()
'This hard coded assuming the "X" are in F4-BN102
Dim strChecked As String
Dim nCount As Integer
nCount = 1
For i = 6 To 66
For j = 4 To 102
strChecked = Sheet2.Cells(j, i)
If UCase(strChecked) = "X" Then
'Debug.Print Sheet2.Cells(j, 4) & "|" & Sheet2.Cells(1, i) & Sheet2.Cells(2, i) & Sheet2.Cells(3, i)
Sheet3.Cells(nCount, 1) = Sheet2.Cells(j, 4)
Sheet3.Cells(nCount, 2) = Sheet2.Cells(1, i) & Sheet2.Cells(2, i) & Sheet2.Cells(3, i)
Sheet3.Cells(nCount, 3) = Sheet2.Cells(j, 2)
nCount = nCount + 1
End If
Next
Next
End Sub