Dear Excel & VBA Experts
I need ur help on data extract from sheet to sheet through column header values, i have set of data on sheet1,2..loop end of sheet
i want pull column data from multiple sheet column values into masterdata sheet depends upon column header values assigned in masterdata sheet.. my code works fine! but i want pull data if column header repeats more than one also
SO_NBR this is one heading in multiple sheets i cant pull col values not more than once under if SO_NBR repeats more than once.
sub pulldata()
Dim rFind As Range, sFind As Range, sAddr As String, ws As Worksheet, rng As Range, LR&, ms As Worksheet
Application.ScreenUpdating = 0
Set ws = Sheets("MASTERDATA")
ws.Range("A2:Fq" & Rows.Count).ClearContents
NR = 2
For Each ms In ActiveWorkbook.Sheets
Set rng = ms.Range("A1:Fq1")
LR = ms.Cells.Find("*", , , , xlByRows, xlPrevious).Row
If ms.Name <> ws.Name Then
For Each sFind In rng
If Len(sFind) Then
With ws.Rows(1)
Set rFind = .Find(sFind, .Cells(.Cells.Count), xlValues, xlWhole)
If Not rFind Is Nothing Then
sAddr = rFind.Address
Do
sFind.Offset(1).Resize(LR - 1).Copy
ws.Cells(NR, rFind.Column).PasteSpecial xlValues
Loop While rFind.Address <> sAddr
sAddr = ""
End If
End With
End If
Next
End If
NR = ws.Cells.Find("*", , , , xlByRows, xlPrevious).Row + 1
Next
Application.CutCopyMode = 0
Set ms = Nothing
Set ws = Nothing
Set rng = Nothing
Set rFind = Nothing
Application.ScreenUpdating = True
End Sub
find the attachment mentioned as expected result sheets is my requirement
Bookmarks