Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Set statement for non active worksheet

Is it possible to (when a different sheet is active)
This is extremely simplified, but represents the problem.
I think I'm hoping "With" carries a little more juice.

Sub WorkingIt()
Dim iWish As Range
With Sheet2.Range("rngOne") ' Named range =Sheet2!$D$7:$G$14
.Range(Cells(3, 3), Cells(4, 4)).Value = 45
Set iWish = .Range(Cells(2, 3), Cells(4, 4))
End With
End Sub
--
Jim at Eagle
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Set statement for non active worksheet

Hi
Nothing wrong with this - Sheet2 need not be active for this to work.
Looking at your code, you might want

Set iWish = .Range(.Cells(2, 3), .Cells(4, 4))

Note the extra periods. This will give you a subrange of "rngOne".
Without the periods it refers to Cells(2,3) to Cells(4,4) on the
worksheet relative to A1.
regards
Paul

On Apr 29, 2:01*pm, Jim at Eagle
wrote:
Is it possible to (when a different sheet is active)
This is extremely simplified, but represents the problem.
I think I'm hoping "With" carries a little more juice.

Sub WorkingIt()
Dim iWish As Range
With Sheet2.Range("rngOne") ' * Named range =Sheet2!$D$7:$G$14
* * .Range(Cells(3, 3), Cells(4, 4)).Value = 45
* * Set iWish = .Range(Cells(2, 3), Cells(4, 4))
End With
End Sub
--
Jim at Eagle


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Set statement for non active worksheet

Thanks for your help. I had to make the sheet active.
when adding the extra periods a error would come up because I'm working With
a range within the sheet.
I posted a new problem just now if you want a real challenge.
--
Jim at Eagle


" wrote:

Hi
Nothing wrong with this - Sheet2 need not be active for this to work.
Looking at your code, you might want

Set iWish = .Range(.Cells(2, 3), .Cells(4, 4))

Note the extra periods. This will give you a subrange of "rngOne".
Without the periods it refers to Cells(2,3) to Cells(4,4) on the
worksheet relative to A1.
regards
Paul

On Apr 29, 2:01 pm, Jim at Eagle
wrote:
Is it possible to (when a different sheet is active)
This is extremely simplified, but represents the problem.
I think I'm hoping "With" carries a little more juice.

Sub WorkingIt()
Dim iWish As Range
With Sheet2.Range("rngOne") ' Named range =Sheet2!$D$7:$G$14
.Range(Cells(3, 3), Cells(4, 4)).Value = 45
Set iWish = .Range(Cells(2, 3), Cells(4, 4))
End With
End Sub
--
Jim at Eagle



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
Copying the active worksheet to another worksheet in the same work queenmaam Excel Worksheet Functions 5 March 25th 08 06:56 PM
Deleting column in a worksheet that is not active worksheet [email protected] Excel Programming 3 October 7th 07 03:33 PM
Basic Question - How do I return the worksheet number of the active worksheet? Regnab Excel Programming 2 May 17th 06 03:02 AM
Altering code to reference the worksheet before the active worksheet KimberlyC Excel Programming 8 March 15th 05 10:26 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM


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