从一个工作簿中复制一个范围(使用R1C1表示法)以粘贴到另一个工作簿中

时间:2019-05-03 17:26:29

标签: excel vba range excel-r1c1-notation

path = ThisWorkbook.path

numTot = 3 

colcol = 71

For nameFile = 1 To numTot

   rigaUltimaWB = ThisWorkbook.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row + 
1

Set src = Workbooks.Open(path & "\" & nameFile & ".csv", True, True)

With src.Sheets(1)

    lCol = .Cells(1, Columns.Count).End(xlToLeft).Column

    lRow = .Cells(Rows.Count, 1).End(xlUp).Row

For i = 1 To lCol

    For j = 1 To colcol

        If .Cells(1, i) = ThisWorkbook.Sheets(1).Cells(1, j) Then

            Range(.Cells(2, i), .Cells(lRow, i)).Copy ThisWorkbook.Sheets(1).Cells(2, j)

        End If

    Next j

Next i

0 个答案:

没有答案