我正在尝试将文本从我的工作表复制到变体工作表。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 –