Új hozzászólás Aktív témák

  • bucihost

    senior tag

    Sziasztok!

    Több excel file-ból kellene adatokat átmásolni egy új excelbe folytatólagosan.

    Találtam erre egy makrót, ami működőképes is lenne, viszont ott 1 adott munkafüzetre érvényes a makró. Ennek átírásában tudna valaki segíteni, hogy a nyitott munkafüzet (ahol lefuttatom a makrót) onnan másolja az adatokat?

    Sub Copy_Paste_Below_Last_Cell()
    'Find the last used row in both sheets and copy and paste data below existing data.

    Dim wsCopy As Worksheet
    Dim wsDest As Worksheet
    Dim lCopyLastRow As Long
    Dim lDestLastRow As Long

      'Set variables for copy and destination sheets
      Set wsCopy = Workbooks("New Data.xlsx").Worksheets("Export 2")
      Set wsDest = Workbooks("Reports.xlsm").Worksheets("All Data")
        
      '1. Find last used row in the copy range based on data in column A
      lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row
        
      '2. Find first blank row in the destination range based on data in column A
      'Offset property moves down 1 row
      lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row

      '3. Copy & Paste Data
      wsCopy.Range("A2:D" & lCopyLastRow).Copy _
       wsDest.Range("A" & lDestLastRow)

    end sub

Új hozzászólás Aktív témák