what this macro doing is ,after enter values to second sheet column "F" it's matching with first sheet("order history") column "M" & picking data to second sheet.
Option Explicit
Sub MoveData(ws As Worksheet, Target As Range)
Dim found As Range
Dim i As Long, r As Long, trow As Long
Dim copyCols, pasteCols
trow = Target.Row
With ThisWorkbook.Sheets("order history")
Set found = .Range("m:m").Find(Left(Target, 6), , -4163)
If Not found Is Nothing Then
r = found.Row
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If r > 2 Then
copyCols = Split("D,H,F,G,I,C", ",")
pasteCols = Split("A,B,C,D,E,H", ",")
If UBound(copyCols) = UBound(pasteCols) Then
For i = 0 To UBound(pasteCols)
Cells(trow, pasteCols(i)).Value = _
.Cells(r, copyCols(i)).Value
Next i
End If
Else
Range("A" & trow & ":E" & trow).ClearContents
Range("H" & trow).ClearContents
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End If
End With
End Sub
at the moment this macro coping first sheet column D,H,F,G,I,C values to second sheet A,B,C,D,E,H.
my requirement is same like others,first sheet column "E" value need to copy to second sheet column "I" ,if first sheet column "E" is empty then same row column "H" value i want to copy to column "I".pls add this modification to this macro.thanks in advance.
Bookmarks