mitko007,
I have been having a problem with my old userid/handle stanleydgrom.
I have created a macro using arrays in memory, in response to your reply #3.
In reference to that workbook:
Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).
Option Explicit
Sub FillStatesMatrixV2()
' stanleydgrom, 07/21/2013 --> hiker95, 07/24/2013
' http://www.vbaexpress.com/forum/showthread.php?t=46902
Dim a As Variant, s As Variant, j As Variant, js As Variant
Dim lrs As Long, lra As Long, i As Long, c As Long, fr As Long, fc As Long
Application.ScreenUpdating = False
With Sheets("Sheet1")
lra = .Cells(Rows.Count, 1).End(xlUp).Row
.Range("J2:S" & lra).Value = 0
j = .Range("J1:S" & lra).Value
js = .Range("J1:S1").Value
a = .Range("A1:A" & lra)
.Range("A1:A" & lra).NumberFormat = "0"
End With
With Sheets("States")
lrs = .Cells(Rows.Count, "L").End(xlUp).Row
s = .Range("K1:L" & lrs).Value
End With
For i = 2 To UBound(s, 1)
fr = 0
On Error Resume Next
fr = Application.Match(s(i, 2), Sheets("Sheet1").Columns(1), 0)
On Error GoTo 0
If fr > 0 Then
fc = 0
For c = 1 To UBound(js, 2)
If s(i, 1) = js(1, c) Then
fc = c
Exit For
End If
Next c
If fc > 0 Then
j(fr, fc) = 1
End If
End If
Next i
With Sheets("Sheet1")
With .Range("A1:A" & lra)
.Value = a
.NumberFormat = "General"
End With
.Range("J1").Resize(UBound(j, 1), UBound(j, 2)) = j
.Activate
End With
Application.ScreenUpdating = True
End Sub
Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm
Then run the FillStatesMatrixV2 macro.
I am not able to download your latest workbook in reply #15.
Can you try using the following free site:
You can upload your workbook to Box Net,
mark the workbook for sharing
and provide us with a link to your workbook.
Have a great day,
hiker95