Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-30-2023, 05:41 AM
NoSparks NoSparks is offline Copy and paste specific cells between Workbooks Windows 10 Copy and paste specific cells between Workbooks Office 2010
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Try this
Code:
Sub CopyData()    'Both Workbooks MUST be open when running the macro.
  Dim wb1 As Workbook
  Dim wb2 As Workbook
  Dim ws1 As Worksheet
  Dim cel As Range
  Dim MyRng As Range
  Dim i As Long
  Dim lrow As Long
  
  Set wb1 = Workbooks("Test - v1 (2023-03-27).xlsm")    'Source
  Set wb2 = Workbooks("Test (no macros) - v1.xlsx")     'Destination
  Set ws1 = wb2.Sheets("Sheet1")                        'Destination Sheet1
  i = 3                                                 'First row to copy to
  
  With wb1.Worksheets("Sheet1")
    lrow = .Range("A" & .Rows.Count).End(xlUp).Row
    Set MyRng = .Range(.Cells(3, 1), .Cells(lrow, 1))
    For Each cel In MyRng
      If cel <> "" Then
        ws1.Range("A" & i) = cel
        ws1.Range("B" & i) = cel.Offset(0, 1)
        'ws1.Range("C" & i) = cel.Offset(0, 2)  'Column C not included as this is a formula
        ws1.Range("D" & i) = cel.Offset(0, 3)
        ws1.Range("E" & i) = cel.Offset(0, 4)
        ws1.Range("F" & i) = cel.Offset(0, 5)
        ws1.Range("G" & i) = cel.Offset(0, 6)
        ws1.Range("H" & i) = cel.Offset(0, 7)
        ws1.Range("I" & i) = cel.Offset(0, 8)
        ws1.Range("J" & i) = cel.Offset(0, 9)
        ws1.Range("K" & i) = cel.Offset(0, 10)
        i = i + 1
      End If
    Next cel
  End With
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy & paste 2 ranges of cells trevorc Excel Programming 14 12-02-2018 03:08 PM
Copy and paste specific cells between Workbooks Range COPY paste in workbooks sheets as variable Fean Excel Programming 3 06-07-2016 06:51 AM
Trying to find a macro that will copy a cell and paste that value to a specific sheet bryans88 Excel Programming 1 12-23-2015 01:40 PM
Copy and paste specific cells between Workbooks Copy/Paste EXCEL cells as pic in WORD A_Lau Drawing and Graphics 3 12-19-2014 06:57 AM
Copy and paste specific cells between Workbooks Find specific rows then copy and paste to new doc konopca Word VBA 5 02-20-2014 02:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft