EXCEL VBA Range

yccyccycc

New Member
Joined
Aug 4, 2011
Messages
23
Hello,

I am creating a file (Total) that can take data from another workbook (Region).

I would like to shorten one part of the codes:

I need to take data from the Regional Workbook from column D3 to AK25 to the destination workbook. Then take D28 - AK 39....and etc. (Basically, I need D3-AK3, D4-AK4, D5-AK5, .......D25 to AK25

I used this but it did not work well.
.Range("xxx:xxx").Value = fromWorkSheetR.Range("D3:AK25").Value

Here is what my alternative.....I wrote it row by row.
With destinationWorkSheet
.Range("B7:AI7").Value = fromWorkSheetR.Range("D2:AK2").Value
.Range("B9:AI9").Value = fromWorkSheetR.Range("D3:AK3").Value
.Range("B10:AI10").Value = fromWorkSheetR.Range("D4:AK4").Value
.Range("B11:AI11").Value = fromWorkSheetR.Range("D5:AK5").Value
.Range("B12:AI12").Value = fromWorkSheetR.Range("D6:AK6").Value
........
........

But there are too many rows to write on....anyway to shorten it?

Thanks!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I used this but it did not work well.
.Range("xxx:xxx").Value = fromWorkSheetR.Range("D3:AK25").Value

This kind of notation should work - if you apply it correctly.

Are the ranges the same size?

Is the With...End With statement correct?

No cell protection?
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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