Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-02-2018, 08:23 PM
kevinbradley57 kevinbradley57 is offline Copy two separate ranges from another workbook Windows 7 64bit Copy two separate ranges from another workbook Office 2010 64bit
Advanced Beginner
Copy two separate ranges from another workbook
 
Join Date: Jul 2017
Posts: 89
kevinbradley57 is on a distinguished road
Default Copy two separate ranges from another workbook

I have a source file called "SearchResultsCompleted m.dd.yy" where m.dd.yy is the current date. It is a system export with one worksheet, named "Archer Search Report". It has data in columns A-L and a header row. The number of rows varies. I have a destination file "Weekly Plan Status m.dd.yy" with worksheet "Completed". I need to copy from the source file the data (not the header row) from columns A-G and H-L to the destination file in columns A-G and I-M. I want Column H of the destination file to have the formula =F2-G2, =F3-G3, etc.

I know just enough VBA to get frustrated. Here's the code I cobbled together from what I could find on various VBA websites. Any help would be appreciated.


Code:
Sub GetCompleted()
 
Application.ScreenUpdating = False
Dim Lastrow As Long
Dim range1 As Range, range2 As Range
Set range1 = Range("A2:G" & Range("G" & Rows.Count).End(xlUp).Row)
Set range2 = Range("H2:K" & Range("H" & Rows.Count).End(xlUp).Row)
 
Workbooks("Weekly Plan Status " & Format(Date, "m.d.yy") & ".xlsm").Worksheets("Completed").range1.Value = _
    Workbooks("SearchResultsCompleted " & _
    Format(Date, "m.d.yy") & ".xls").Worksheets("Archer Search Report").range1.Value

Range("$H$2").Formula = xxx

Lastrow = Range("H" & Rows.Count).End(xlUp).Row
Range("H2").FormulaR1C1 = xxx
Range("H2").AutoFill Destination:=Range(“H3:H" & Lastrow)
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
 
End Sub

Last edited by kevinbradley57; 06-03-2018 at 06:40 AM.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy data as well as formatting from one workbook to another. LearnerExcel Excel 1 03-10-2018 01:35 PM
Copy from one workbook to another MartinExcel11 Excel Programming 1 03-28-2017 09:49 AM
Copy two separate ranges from another workbook Take String of numbers, expand ranges, sort, then compress back into ranges AustinBrister Word VBA 19 08-22-2016 05:18 PM
How to make a shared workbook and allow user to edit ranges prdecina Excel 1 07-25-2016 11:42 PM
Copy two separate ranges from another workbook Storing and retreiving text from a separate workbook Benjamin92 Excel Programming 4 03-08-2015 04:20 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:32 AM.


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