Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try stepping through this in a general module:
Option Explicit Sub testme() Dim ws As Worksheet Dim ws1 As Worksheet Dim rng As Range Set ws = Worksheets.Add Set ws1 = Worksheets.Add ws1.Select 'this works Set rng = ws.Range(ws.Cells(2, 1), ws.Cells(3, 1)) 'how about: Set rng = ws.Range(Cells(2, 1), Cells(3, 1)) 'how about Set rng = Range(ws.Cells(2, 1), ws.Cells(3, 1)) End Sub Now copy the exact code and put it behind a worksheet and step through it. You may want to comment out the failing step and rerun to get to the other lines. Gary Keramidas wrote: thanks dave and tom. they all seemed to work for me, but i guess qualifying them every range is the best bet. -- Gary "Tom Ogilvy" wrote in message ... the summation. If you qualify one, qualify all. If not, qualify none (choosing something in between is a waste of time and effort). -- Regards, Tom Ogilvy "Dave Peterson" wrote: The top one is my favorite of your 3 choices--only because the bottom two may fail. this one: ws.range(cells(2,1),cells(3,1)).select didn't qualify the cells(). This one: range(ws.cells(2,1),ws.cells(3,1)) didn't qualify the range(). It'll depend on where the code is and what the activesheet is and what ws is. If you hit the perfect storm, you may have to spend time debugging. Gary Keramidas wrote: may have asked this before, but which of these is preferable? (disregarding the select<g) ws.range(ws.cells(2,1),ws.cells(3,1)).select ws.range(cells(2,1),cells(3,1)).select range(ws.cells(2,1),ws.cells(3,1)).select -- Gary -- Dave Peterson -- Dave Peterson |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i see what you mean.
-- Gary "Dave Peterson" wrote in message ... Try stepping through this in a general module: Option Explicit Sub testme() Dim ws As Worksheet Dim ws1 As Worksheet Dim rng As Range Set ws = Worksheets.Add Set ws1 = Worksheets.Add ws1.Select 'this works Set rng = ws.Range(ws.Cells(2, 1), ws.Cells(3, 1)) 'how about: Set rng = ws.Range(Cells(2, 1), Cells(3, 1)) 'how about Set rng = Range(ws.Cells(2, 1), ws.Cells(3, 1)) End Sub Now copy the exact code and put it behind a worksheet and step through it. You may want to comment out the failing step and rerun to get to the other lines. Gary Keramidas wrote: thanks dave and tom. they all seemed to work for me, but i guess qualifying them every range is the best bet. -- Gary "Tom Ogilvy" wrote in message ... the summation. If you qualify one, qualify all. If not, qualify none (choosing something in between is a waste of time and effort). -- Regards, Tom Ogilvy "Dave Peterson" wrote: The top one is my favorite of your 3 choices--only because the bottom two may fail. this one: ws.range(cells(2,1),cells(3,1)).select didn't qualify the cells(). This one: range(ws.cells(2,1),ws.cells(3,1)) didn't qualify the range(). It'll depend on where the code is and what the activesheet is and what ws is. If you hit the perfect storm, you may have to spend time debugging. Gary Keramidas wrote: may have asked this before, but which of these is preferable? (disregarding the select<g) ws.range(ws.cells(2,1),ws.cells(3,1)).select ws.range(cells(2,1),cells(3,1)).select range(ws.cells(2,1),ws.cells(3,1)).select -- Gary -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I enter formula sum(range+range)*0.15 sumif(range=3) | Excel Discussion (Misc queries) | |||
Using a variable in a Rows Hidden Staement | Excel Programming | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
If staement and macro | Excel Programming | |||
how to? set my range= my UDF argument (range vs. value in range) [advanced?] | Excel Programming |