Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default Reset my object variable myRng1 with each loop

I'm setting in my FIRST Worksheet an object variable myRng1 by using code line:
Set myRng1 = Application.InputBox("Highlight the range you wish to Extract",
Type:=8)
This extract range ($P$80:$P$84) will remain the same for all successive
worksheet I loop through. I just need my myRng1 to "reflect" the current
sheet name as it loops, versus the original sheet name. See <PROBLEM Line
Below

my loop does as follows:
For i = StartSheetIdxNum To NumSheetsToEnd
Sheets(i).Activate
If i StartSheetIdxNum Then
Application.Goto Reference:=Range(mcell), Scroll:=True
Set myRng1 = Range(ActiveSheet.Name & "!" & Range(myRng1)) ' <PROBLEM
End If
ReDim MySArr(1 To numCells + 1, 1 To NumSheetsToEnd)
MySArr(1, c) = ActiveSheet.Name
For r = 2 To numCells + 1
MySArr(r, c) = myRng1(r - 1).Value
Next r
Call GoHome

Thanks in Advance,,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Reset my object variable myRng1 with each loop

For i = StartSheetIdxNum To NumSheetsToEnd
Sheets(i).Activate
If i StartSheetIdxNum Then
Application.Goto Reference:=Range(mcell), Scroll:=True
Set myRng1 =Activesheet.Range(myRng1.Address) ' <PROBLEM
End If
ReDim MySArr(1 To numCells + 1, 1 To NumSheetsToEnd)
MySArr(1, c) = ActiveSheet.Name
For r = 2 To numCells + 1
MySArr(r, c) = myRng1(r - 1).Value
Next r
Call GoHome

--
Regards,
Tom Ogilvy


"JMay" wrote:

I'm setting in my FIRST Worksheet an object variable myRng1 by using code line:
Set myRng1 = Application.InputBox("Highlight the range you wish to Extract",
Type:=8)
This extract range ($P$80:$P$84) will remain the same for all successive
worksheet I loop through. I just need my myRng1 to "reflect" the current
sheet name as it loops, versus the original sheet name. See <PROBLEM Line
Below

my loop does as follows:
For i = StartSheetIdxNum To NumSheetsToEnd
Sheets(i).Activate
If i StartSheetIdxNum Then
Application.Goto Reference:=Range(mcell), Scroll:=True
Set myRng1 = Range(ActiveSheet.Name & "!" & Range(myRng1)) ' <PROBLEM
End If
ReDim MySArr(1 To numCells + 1, 1 To NumSheetsToEnd)
MySArr(1, c) = ActiveSheet.Name
For r = 2 To numCells + 1
MySArr(r, c) = myRng1(r - 1).Value
Next r
Call GoHome

Thanks in Advance,,

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Reset my object variable myRng1 with each loop

Set myRng1 = Range(ActiveSheet.Name & "!" & myRng1.Address)


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"JMay" wrote in message
...
I'm setting in my FIRST Worksheet an object variable myRng1 by using code
line:
Set myRng1 = Application.InputBox("Highlight the range you wish to
Extract",
Type:=8)
This extract range ($P$80:$P$84) will remain the same for all successive
worksheet I loop through. I just need my myRng1 to "reflect" the current
sheet name as it loops, versus the original sheet name. See <PROBLEM
Line
Below

my loop does as follows:
For i = StartSheetIdxNum To NumSheetsToEnd
Sheets(i).Activate
If i StartSheetIdxNum Then
Application.Goto Reference:=Range(mcell), Scroll:=True
Set myRng1 = Range(ActiveSheet.Name & "!" & Range(myRng1)) '
<PROBLEM
End If
ReDim MySArr(1 To numCells + 1, 1 To NumSheetsToEnd)
MySArr(1, c) = ActiveSheet.Name
For r = 2 To numCells + 1
MySArr(r, c) = myRng1(r - 1).Value
Next r
Call GoHome

Thanks in Advance,,



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default Reset my object variable myRng1 with each loop

Thanks BOTH Tom and Bob;;;


"Bob Phillips" wrote:

Set myRng1 = Range(ActiveSheet.Name & "!" & myRng1.Address)


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"JMay" wrote in message
...
I'm setting in my FIRST Worksheet an object variable myRng1 by using code
line:
Set myRng1 = Application.InputBox("Highlight the range you wish to
Extract",
Type:=8)
This extract range ($P$80:$P$84) will remain the same for all successive
worksheet I loop through. I just need my myRng1 to "reflect" the current
sheet name as it loops, versus the original sheet name. See <PROBLEM
Line
Below

my loop does as follows:
For i = StartSheetIdxNum To NumSheetsToEnd
Sheets(i).Activate
If i StartSheetIdxNum Then
Application.Goto Reference:=Range(mcell), Scroll:=True
Set myRng1 = Range(ActiveSheet.Name & "!" & Range(myRng1)) '
<PROBLEM
End If
ReDim MySArr(1 To numCells + 1, 1 To NumSheetsToEnd)
MySArr(1, c) = ActiveSheet.Name
For r = 2 To numCells + 1
MySArr(r, c) = myRng1(r - 1).Value
Next r
Call GoHome

Thanks in Advance,,




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
reset the range of FOR loop Farooq Sheri Excel Discussion (Misc queries) 1 April 7th 09 08:05 PM
Is it possible to reset the starting cell in a For Loop Ayo Excel Discussion (Misc queries) 2 May 12th 08 06:27 PM
use a variable to name an object in a loop m davidson Excel Programming 7 April 19th 06 10:19 AM
Problems Defining Object Variable in For Each Loop ExcelMonkey[_190_] Excel Programming 7 February 28th 05 10:46 PM
variable that keeps its value until reset Jamie Martin[_2_] Excel Programming 2 September 30th 03 05:57 AM


All times are GMT +1. The time now is 07:36 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"