我正在嘗試將文本從我的工作表複製到變體工作表。Excel根據單元格值複製到特定工作表
我想要的是將單元格J19,J20,J21複製到不同工作表的單元格A1,B1,C1。 J19決定將哪個工作表複製到每個代理程序都有自己的工作表,其中有一個宏將代理程序名稱拉到J19上進行數據驗證。
J19 =代理名稱
J20 =假日開始日期
J21 =假日結束日期
如何更改Set wsDestin = Sheets("Agent1")
以便它看起來在J19來決定目標單元格。
Sub CopyColumnP()
Dim wsSource As Worksheet
Dim wsDestin As Worksheet
Dim lngDestinRow As Long
Dim rngSource As Range
Dim rngCel As Range
Set wsSource = Sheets("Front")
Set wsDestin = Sheets("Agent1")
With wsSource
Set rngSource = .Range(.Cells(19, "J"), .Cells(.Rows.Count, "J").End(xlUp))
End With
For Each rngCel In rngSource
If rngCel.Value = "Design" Then
With wsDestin
lngDestinRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
rngCel.EntireRow.Copy Destination:=wsDestin.Cells(lngDestinRow, "A")
End With
End If
Next rngCel
End Sub
單元格(「J19」)。值 – Luuklag
真的那麼簡單嗎?我認爲這會更復雜@Luuklag –