Re: Match Columns heading and Copy data across 3 worksheets - Excel VBA
how to do this with if statement. for example if in column 5 there is a signed & Negative items so how to pull only signed items from that sheet and paste columns wise data? Please help its urgent. Below is the code how to add if statement in this code.
Sub UpDateData()
Application.ScreenUpdating = False
Dim I As Long, j As Long, k As Long, n As Long, wData As Worksheet
Dim EndRow As Long
Dim counter As Long
Set wData = Sheets("Smartbox_Installation")
I = 7
With Sheets("Master_Database")
n = .Cells(.Rows.Count, 7).End(xlUp).Row
For j = 2 To .Cells(7, .Columns.Count).End(xlToLeft).Column
k = Application.Match(.Cells(7, j), wData.Rows(7), 0)
.Cells(7, j).Resize(n - 1).copy wData.Cells(I, k).Resize(n - 1)
Sheet10.Range("B8:AD1000").Select
Selection.Sort Key1:=Sheet10.Range("AD8"), Order1:=xlAscending, _
OrderCustom:=1, MatchCase:=True
EndRow = Sheet10.Range("D" & Rows.Count).End(xlUp).Row
For counter = 8 To EndRow
Sheet10.Range("A" & counter).Value = counter - 7
Next counter
Next j
Application.CutCopyMode = False
Range("A8").Select
'MsgBox "Data Update"
End With
End Sub