hello
I try copying data from sheets(import,export) to sheet inventory . the sheet INVENTORY contains the headers . it should match with sheets (import,export) and copy the data without repeatedly when run the macro continuosly .
so this is what I have but it gives error object required in this line
For i = 0 To UBound(cols)
Sub Copy_Columns()
Dim cols, sh As Variant, sh2 As Worksheet, i, s As Long, c As Long, f As Range
Set sh2 = Sheets("INVENTORY")
sh = Array("export", "import")
cols = Array("BRAND", "MODEL", "CLIENT", "QTY IMP", "QTY EX") 'Put column titles here
For s = 0 To UBound(sh)
Sheets(sh(s)).Activate
For i = 0 To UBound(cols)
Set f = sh.Rows(1).Find(cols(i), , xlValues, xlWhole)
If Not f Is Nothing Then
c = f.Column
Set f = sh2.Rows(1).Find(cols(i), , xlValues, xlWhole)
If Not f Is Nothing Then
sh.Columns(c).Copy sh2.Columns(f.Column)
End If
End If
Next
Next
MsgBox "End"
End Sub