Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 331
Default looping thru named ranges

Hi,

I have a bunch of pairs of named ranges, all of them consist of some
leading identifier followed by LIVE or HARD, for instance spLIVE, spHARD;
RussellLIVE, RussellHARD, etc.

How would I loop through the range collection and copy/ paste values each
LIVE range into respective HARD range?

Thank you,

--
______
Regards,
Greg
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default looping thru named ranges

One way:

Dim nmTest As Name
Dim rDest As Range
Dim rSource As Range
Dim sTest As String
For Each nmTest In ActiveWorkbook.Names
sTest = nmTest.Name
If sTest Like "*LIVE" Then
sTest = Left(sTest, Len(sTest) - 4) & "HARD"
On Error Resume Next
Set rSource = nmTest.RefersToRange
Set rDest = ActiveWorkbook.Names(sTest).RefersToRange
On Error GoTo 0
If Not rDest Is Nothing And Not rSource Is Nothing Then _
rSource.Copy Destination:=rDest
End If
Next nmTest


In article ,
Greg wrote:

Hi,

I have a bunch of pairs of named ranges, all of them consist of some
leading identifier followed by LIVE or HARD, for instance spLIVE, spHARD;
RussellLIVE, RussellHARD, etc.

How would I loop through the range collection and copy/ paste values each
LIVE range into respective HARD range?

Thank you,

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
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Excel Programming 3 December 24th 07 01:15 PM
Copy data in named ranges to a newer version of the same template to identical ranges handstand Excel Programming 0 August 21st 06 03:51 PM
Looping through named ranges JFamilo[_12_] Excel Programming 2 August 17th 05 02:23 PM
Deleting named ranges by looping through range collection agarwaldvk[_11_] Excel Programming 3 August 3rd 04 01:00 AM
Looping through named ranges Tim[_38_] Excel Programming 1 May 10th 04 07:20 PM


All times are GMT +1. The time now is 05:01 AM.

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

About Us

"It's about Microsoft Excel"