Hi

Try this

Sub kTest()

    Dim ka, k(), i As Long, c As Long, n As Long, Hdr, x
    Dim wks As Worksheet, Flds

    Hdr = Array("NAME", "Specialty_name", "Office_name", "Address_1",
"Address_2", _
                "Address", "Phone_number_1", "Fax_number")

    ka = Sheets("Sheet1").Range("a1").CurrentRegion.Value2
    Flds = Application.Index(ka, 1, 0)
    ReDim k(1 To UBound(ka, 1) * (UBound(Hdr) + 1) + UBound(Hdr) + 1, 1 To
1)

    For i = 2 To UBound(ka, 1)
        For c = 0 To UBound(Hdr)
            x = Application.Match(Hdr(c), Flds, 0)
            If Not IsError(x) Then
                If Len(ka(i, x)) Then
                    n = n + 1
                    k(n, 1) = ka(i, x)
                End If
            End If
        Next
        n = n + 1
    Next

    On Error Resume Next
    Set wks = Worksheets("Result")
    On Error GoTo 0
    If wks Is Nothing Then
        Set wks = Worksheets.Add
        wks.Name = "Result"
    End If

    wks.Range("a1").Resize(n) = k

End Sub

Kris
ExcelFox <http://www.excelfox.com/forum/forum.php>

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to