LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Junior Member
 
Posts: 29
Default VBA Copy & Paste multiple ranges

Hi, I have the following code to take figures from a hidden worksheet and to place them into specific cells in a visible worksheet in the same workbook.

Dim ShGet As Worksheet
Dim ShDest As Worksheet
Dim ShStart As Worksheet
Set ShGet = Sheets("GetValues")
Set ShDest = Sheets("PasteValues")
Set ShStart = Sheets("Start")

If ShStart.Range("A1").Value = "one" Then
ShDest.Range("F9:AC9").Value = ShGet.Range("C204:Z204").Value
ShDest.Range("F15:AC15").Value = ShGet.Range("C207:Z207").Value
ElseIf ShStart.Range("P40").Value = "two" Then
ShDest.Range("F9:AC9").Value = ShGet.Range("C204:Z204").Value
ShDest.Range("F15:AC15").Value = ShGet.Range("C207:Z207").Value
ElseIf ShStart.Range("P40").Value = "three" Then
ShDest.Range("F9:AC9").Value = ShGet.Range("C204:Z204").Value
ShDest.Range("F15:AC15").Value = ShGet.Range("C207:Z207").Value
ElseIf ShStart.Range("P40").Value = "four" Then
ShDest.Range("F9:AC9").Value = ShGet.Range("C204:Z204").Value
ShDest.Range("F15:AC15").Value = ShGet.Range("C207:Z207").Value
End If

NB: I've only placed two ranges in each if/elseif, but actually I have about 100+ rows that will need to be pulled across to the destination sheet. My question is is there a better way to do this than my approach above? The "GetValues" are all in one continuous block but the destination cells will be placed on specific rows and not (i.e. rows 11, 13, 24, 26, 46, 48, etc). The ranges will not change.

Thanks in advance.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I copy big ranges of cells without drag or copy/paste? Ricardo Julio Excel Discussion (Misc queries) 3 March 23rd 10 02:38 PM
Copy/Paste dynamic ranges kevin Excel Programming 1 May 28th 09 09:06 PM
copy then paste to multiple ranges MJKelly Excel Programming 3 October 15th 08 01:39 PM
Copy and paste Named Ranges Robert H Excel Programming 6 February 6th 07 04:13 PM
Copy paste ranges from multiple sheets Woody1313 Excel Programming 2 January 30th 06 03:37 PM


All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"