I am looking for a macro that do the things mentioned below
If column I of 1.xls matches with column B of H2.xlsb then put the data in series in that row
Macro will be placed in H2.xlsb
This is the variation of this post
Code: Select all
Sub Macrotest()
Dim Ws1 As Worksheet, Ws2 As Worksheet, a, r As Range, x, myVal
Dim Wb1 As Workbook, Wb2 As Workbook
Set Wb1 = Workbooks.Open("C:\Users\**I've been banned**\Desktop\1.xls")
Set Ws1 = Wb1.Worksheets.Item(1)
Set Wb2 = ActiveWorkbook
Set Ws2 = Wb2.Worksheets.Item(1)
With Ws1
a = .Cells(1).CurrentRegion.Columns("i").Value
.Parent.Close False
End With
With Ws2
For Each r In .Range("b2", .Range("b" & Rows.Count).End(xlUp))
myVal = r.Value
If Not IsNumeric(myVal) Then myVal = Chr(34) & myVal & Chr(34)
x = Application.Match(r.Value, a, 0)
If IsNumeric(x) Then
With .Cells(r.Row, Columns.Count).End(xlToLeft)
.Cells(1, 2) = .Value + 1
End With
End If
Next
End With
End Sub
Wb1.Close
Wb2.Save
End Sub
https://www.excelforum.com/excel-progra ... ost5363466