VBA to copy from one book and paste to another

WORK: To copy RANGE from one WORKING BOOK to ANOTHER (ANOTHER textbook exists and must be open)

  • Copy Range:

    `Worksheets("paste").Range("A2:BD500").SpecialCells(xlCellTypeVisible).Copy`
    
  • Open a new file:

    Workbooks.Open Filename:="C:\Test\test.xlsx", WriteResPassword:="WriteFile"

  • Activate sheets and insert @RANGE A6

    Windows("test.xlsx").Activate Selection.Range("A6").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

PROBLEM: he does not insert A6 !!!! This happens in any cell !!!!

+4
source share
2 answers

If your current selection in the test.xlsx workbook opens on D5, use the Selection.Range("A6")links D10, not A6.

Dim wb As Workbook

Set wb = Workbooks.Open(Filename:="C:\Test\test.xlsx", WriteResPassword:="WriteFile")

With Worksheets("paste")
    .Range("A2:BD500").SpecialCells(xlCellTypeVisible).Copy
    wb.Worksheets(1).Cells(6, "A").PasteSpecial xlPasteValues
End With

. Excel VBA. , .

+4

:

Workbooks(source).Worksheets("Sheet1").Range("A2:BD500").Copy _
    Workbooks(destination).Worksheets("Sheet1").Range("A6")
0

Source: https://habr.com/ru/post/1672285/


All Articles