CODE INPUT DATA TỪ SAP -> Master Data Release
Sub InputData_AutoFindBatch()
Dim srcSheet As Worksheet, dstSheet As Worksheet
Dim batchID As String
Dim foundCell As Range
Dim rowDst As Long
Set srcSheet = [Link]("Input data")
Set dstSheet = [Link]("MASTER DATA")
' Get Batch ID from B3
batchID = [Link]("B2").Value
' Search for batch ID in column C
Set foundCell = [Link]("C:C").Find(What:=batchID, LookIn:=xlValues,
LookAt:=xlWhole)
If foundCell Is Nothing Then
MsgBox "Batch not found: " & batchID, vbExclamation
Exit Sub
End If
rowDst = [Link]
' Paste values from Input data to MASTER DATA
With dstSheet
.Cells(rowDst, "R").Value = [Link]("B4").Value
.Cells(rowDst, "U").Value = [Link]("B5").Value
.Cells(rowDst, "T").Value = [Link]("B6").Value
.Cells(rowDst, "S").Value = [Link]("B7").Value
.Cells(rowDst, "Z").Value = [Link]("B8").Value
.Cells(rowDst, "X").Resize(1, 2).Value =
[Link]([Link]("B9:B10").Value)
.Cells(rowDst, "W").Value = [Link]("B11").Value
.Cells(rowDst, "AB").Value = [Link]("B12").Value
.Cells(rowDst, "AA").Value = [Link]("B13").Value
.Cells(rowDst, "L").Value = [Link]("B14").Value
.Cells(rowDst, "M").Value = [Link]("B15").Value
.Cells(rowDst, "O").Value = [Link]("B16").Value
.Cells(rowDst, "Q").Value = [Link]("B17").Value
.Cells(rowDst, "V").Value = [Link]("B18").Value
.Cells(rowDst, "P").Value = [Link]("B19").Value
.Cells(rowDst, "N").Value = [Link]("B20").Value
.Range("AD" & rowDst & ":AF" & rowDst).Value =
[Link]([Link]("B21").Value)
.Cells(rowDst, "AG").Value = [Link]("B22").Value
.Cells(rowDst, "AH").Value = [Link]("B23").Value
.Cells(rowDst, "AI").Value = [Link]("B24").Value
.Cells(rowDst, "AC").Value = [Link]("B25").Value
End With
MsgBox "Data successfully entered for batch " & batchID, vbInformation
End Sub