如何用vba在excel中读取某列的数据添加到另一表的对应行

2025-01-24 02:03:04
推荐回答(3个)
回答1:

Sub iTans()
   Dim a, r, rg As Range
   Set rg = Sheet1.Range("A1:A9")
    a= rg
   With Sheet2
       r = .Cells(Rows.Count, "A").End(xlUp).Row
       .Cells(r + 1, "A").Resize(UBound(a, 2), UBound(a, 1)) _
           = Application.Transpose(a)
   End With
End Sub

回答2:

Public Sub 痒痒养羊()
For i = 1 To 3
For j = 2 To 4
If Left(Sheet2.Cells(1, i), 1) = Sheet1.Cells(j, 1) Then
k = Sheet2.Cells(1, i).End(xlDown).Row
For m = 2 To k
Sheet1.Cells(j, m) = Sheet2.Cells(m, i)
Next
End If
Next
Next
End Sub

回答3:

for i=1 to 100
Sheet2.range("A" & i)=Sheet1.range("A" & i)
next