Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default repeat procedure with new range

hello,
Can you help? I would like to repeat this procedure by giving X1 a new range
definition each time (X1=range("country1"), X1=range("country2"), etc)

Union(X1, _
Range(X1.Offset(3, 3), X1.Offset(18, 14)), _
Range(X1.Offset(43, 3), X1.Offset(52, 14)), _
Range(X1.Offset(71, 3), X1.Offset(80, 14)), _
Range(X1.Offset(92, 3), X1.Offset(101, 14)), _
Range(X1.Offset(174, 3), X1.Offset(193, 14)), _
Range(X1.Offset(224, 4), X1.Offset(225, 14))).ClearContents

Any idea?Thanks
--
caroline
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default repeat procedure with new range

Caroline,
How about the following

Sub Test()
Dim i%
Dim x as Range
Dim asRangeNames(1 to 10)
asRangeNames(1)="Country1"
asRangeNames(2)="Country2"
'and so on

for i = 1 to ubound(asRangeNames)

set x = Range(asRangeNames(i))

Union(X1, _
Range(X1.Offset(3, 3), X1.Offset(18, 14)), _
Range(X1.Offset(43, 3), X1.Offset(52, 14)), _
Range(X1.Offset(71, 3), X1.Offset(80, 14)), _
Range(X1.Offset(92, 3), X1.Offset(101, 14)), _
Range(X1.Offset(174, 3), X1.Offset(193, 14)), _
Range(X1.Offset(224, 4), X1.Offset(225, 14))).ClearContents

Next i

End Sub

"caroline" wrote:

hello,
Can you help? I would like to repeat this procedure by giving X1 a new range
definition each time (X1=range("country1"), X1=range("country2"), etc)

Union(X1, _
Range(X1.Offset(3, 3), X1.Offset(18, 14)), _
Range(X1.Offset(43, 3), X1.Offset(52, 14)), _
Range(X1.Offset(71, 3), X1.Offset(80, 14)), _
Range(X1.Offset(92, 3), X1.Offset(101, 14)), _
Range(X1.Offset(174, 3), X1.Offset(193, 14)), _
Range(X1.Offset(224, 4), X1.Offset(225, 14))).ClearContents

Any idea?Thanks
--
caroline

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default repeat procedure with new range

It works thanks a lot
--
caroline


"Alok" wrote:

Caroline,
How about the following

Sub Test()
Dim i%
Dim x as Range
Dim asRangeNames(1 to 10)
asRangeNames(1)="Country1"
asRangeNames(2)="Country2"
'and so on

for i = 1 to ubound(asRangeNames)

set x = Range(asRangeNames(i))

Union(X1, _
Range(X1.Offset(3, 3), X1.Offset(18, 14)), _
Range(X1.Offset(43, 3), X1.Offset(52, 14)), _
Range(X1.Offset(71, 3), X1.Offset(80, 14)), _
Range(X1.Offset(92, 3), X1.Offset(101, 14)), _
Range(X1.Offset(174, 3), X1.Offset(193, 14)), _
Range(X1.Offset(224, 4), X1.Offset(225, 14))).ClearContents

Next i

End Sub

"caroline" wrote:

hello,
Can you help? I would like to repeat this procedure by giving X1 a new range
definition each time (X1=range("country1"), X1=range("country2"), etc)

Union(X1, _
Range(X1.Offset(3, 3), X1.Offset(18, 14)), _
Range(X1.Offset(43, 3), X1.Offset(52, 14)), _
Range(X1.Offset(71, 3), X1.Offset(80, 14)), _
Range(X1.Offset(92, 3), X1.Offset(101, 14)), _
Range(X1.Offset(174, 3), X1.Offset(193, 14)), _
Range(X1.Offset(224, 4), X1.Offset(225, 14))).ClearContents

Any idea?Thanks
--
caroline

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
deselecting a highlighted range after a VBA copy procedure Paul James[_3_] Excel Programming 6 April 25th 23 03:47 AM
Why can't I repeat a sort on another range of a worksheet? DistantFlier Excel Worksheet Functions 0 January 19th 10 09:38 PM
In Before Close Sub ActiveWorkBook.Close(False) repeat procedure [email protected] Excel Programming 5 September 26th 06 03:11 PM
Trying to repeat a procedure TimT Excel Programming 2 August 18th 05 07:27 PM
Error: The procedure number is out of range Van S. Mabrito Excel Programming 1 February 19th 04 11:33 AM


All times are GMT +1. The time now is 03:36 AM.

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"