Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default VBA Copy & Paste multiple ranges

Here's one example that uses the info as you provided...

Sub TransferData()
Const sXfers1$ = "A1=one,F9:AC9=C204:Z204,F15:AC15=C207:Z207"
Const sXfers2$ = "P40=two,F9:AC9=C204:Z204,F15:AC15=C207:Z207"
Const sXfers3$ = "P40=three,F9:AC9=C204:Z204,F15:AC15=C207:Z207 "
Const sXfers4$ = "P40=four,F9:AC9=C204:Z204,F15:AC15=C207:Z207"

Dim vDataXfers$(1 To 4), vRef, v, n&, k&
Dim wksSource As Worksheet, wksTarget As Worksheet

vDataXfers(1) = sXfers1: vDataXfers(2) = sXfers2
vDataXfers(3) = sXfers3: vDataXfers(4) = sXfers4
Set wksSource = Sheets("GetValues"): Set wksTarget =
Sheets("PasteValues")

For n = LBound(vDataXfers) To UBound(vDataXfers)
v = Split(vDataXfers(n), ","): vRef = Split(v(0), "=")
If Sheets("Start").Range(vRef(0)) = vRef(1) Then
For k = 1 To UBound(v)
vRef = Split(v(k), "=")
wksTarget.Range(vRef(0)).Value = wksSource.Range(vRef(1)).Value
Next 'k
End If
Next 'n
End Sub

...where sXfers# is a delimited string 'list' of delimited value pairs,
starting with the criteria for the If evaluation. (Since the range
addresses use the colon character I changed my original list delimiter
from a colon to a comma) Edit the 4 sXfers# strings to match your
needs.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Reply
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 02:52 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"