Simple macro too export range of cols between two w/books .

Sunline

Well-known Member
Joined
Oct 6, 2007
Messages
701
Office Version
  1. 2016
Platform
  1. Windows
Hello all , again have looked thru past posts but not found a simple
macro following .

I want too export from book1 , sheet1 , cols range CG2:DJ2 all data in every row
containing any type of text or numbers including currency etc .

There are 170,000 rows so some speed would be good .

Export too book2 , sheet1 , col range CF2:DI2

Some cells will be blank so leave blank , basically if a photo was taken of book1
data too export it will look and fit into book2 cols CF2:DI2 fillng all 170,000 rows .

I have never done this before any pointers to help will be appreciated . I usually leave out some vital info on my posts but not intentional .

Thanks .
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
What namely range you need to transfer? CG2:DJ170000?
 
Upvote 0
Hi , yes it would be CG2:DJ170000 , sorry left that out .
As mentioned if this could have maximum speed .
Thanks .
 
Upvote 0
Code:
[COLOR="Blue"]Sub[/COLOR] TransferData()
    Workbooks("Book1").Sheets("Sheet1").Range("CG2:DJ170000").Copy _
        Workbooks("Book2").Sheets("Sheet1").Range("CF2")
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0
Wow , Thanks Sektor , did it all in a couple of minutes , was expecting this macro to be huge and slow . All this time ive been spending days cutting and pasting .

Perfect , thankyou very much .
 
Upvote 0
I spoke too soon .
All is good with that macro . Working perfectly .

How would i transfer data from the range mentioned if that data was from the result of a function , when i do this im getting #REF! error .

Im only guessing , somehow deactivate the function in book1 or add a piece to macro to allow it to transfer if data from a function .
Thanks .
 
Upvote 0
Macro transfers EVERYTHING! If you get #REF, this just means that some formulas depended on values which don't exist in your new workbook.
 
Upvote 0
Ok , that totally makes sence .
Stupid question now , sort of asked it before .
Is there anyway i can in book1 use the function i need , then keep that data there as a result from the function , somehow lock that data in the cols then remove function either from the col or that w/book so i can then transfer data too book2 , stupid i know . I can see a NO coming .
Thanks .
 
Upvote 0
May be you should transfer source data along with CG2:DJ170000?
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top