Set RN = Range(Cells(2, 1), Cells(r, 1)) error

What wrong with this.  It create error.  How can I improve to get rid the 
error?

 Set RN = Range(Cells(2, 1), Cells(r, 1))

Thanks
Daniel
0
Daniel1 (174)
6/15/2007 8:20:01 PM
excel.charting 18370 articles. 0 followers. Follow

3 Replies
1139 Views

Similar Articles

[PageSpeed] 58

Hi Daniel,

Too much missing information - has r been declared and what data type is it 
and what value does it have.  What property of the range are you trying to 
store in the variable RN?  What type of variable is RN and has it been 
declared.  
-- 
Thanks,
Shane Devenshire


"Daniel" wrote:

> What wrong with this.  It create error.  How can I improve to get rid the 
> error?
> 
>  Set RN = Range(Cells(2, 1), Cells(r, 1))
> 
> Thanks
> Daniel
0
6/16/2007 4:13:00 AM
Make sure variables are declared and defined, and make sure you reference 
potentially indeterminate ranges.

  Dim RN As Range
  Dim wks As Worksheet
  Dim r As Long

  Set wks = ActiveWorkbook.Worksheets("My Sheet")
  r = 100

  Set RN = wks.Range(wks.Cells(2,1), wks.Cells(r, 1))

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______



"Daniel" <Daniel@discussions.microsoft.com> wrote in message 
news:9E789596-173D-4DCE-BC37-9E98655A0BF0@microsoft.com...
> What wrong with this.  It create error.  How can I improve to get rid the
> error?
>
> Set RN = Range(Cells(2, 1), Cells(r, 1))
>
> Thanks
> Daniel 


0
jonxlmvpNO (4558)
6/17/2007 6:26:30 PM
Hi,

The reason Jon and I are pointing these issues out is that your single line 
of code is fine.  The reason it fails is something else is wrong and Jon and 
I can't see your code so we are just suggesting the most likely places.

Fact is, code that fails on a particular line can fail despite the fact that 
the line is correct. 
-- 
Thanks,
Shane Devenshire


"Jon Peltier" wrote:

> Make sure variables are declared and defined, and make sure you reference 
> potentially indeterminate ranges.
> 
>   Dim RN As Range
>   Dim wks As Worksheet
>   Dim r As Long
> 
>   Set wks = ActiveWorkbook.Worksheets("My Sheet")
>   r = 100
> 
>   Set RN = wks.Range(wks.Cells(2,1), wks.Cells(r, 1))
> 
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> Peltier Technical Services, Inc. - http://PeltierTech.com
> _______
> 
> 
> 
> "Daniel" <Daniel@discussions.microsoft.com> wrote in message 
> news:9E789596-173D-4DCE-BC37-9E98655A0BF0@microsoft.com...
> > What wrong with this.  It create error.  How can I improve to get rid the
> > error?
> >
> > Set RN = Range(Cells(2, 1), Cells(r, 1))
> >
> > Thanks
> > Daniel 
> 
> 
> 
0
6/17/2007 7:30:00 PM
Reply:

Similar Artilces:

Outlook 2003 keeps crashing #2
I get this message when I look in System information. Outlook keeps crashing quite often. I cannot for example delete two messages without outlook crashing. My colleagues do not have this problem. We are using the Microsoft mail exhange server. Faulting application outlook.exe, version 11.0.5510.0, stamp 3f1380f0, faulting module mso.dll, version 11.0.5606.0, stamp 3f334cce, debug? 0, fault address 0x003b6e16. Does anyone has a solution?=20 Best regards/ Bj=F6rn 1) I would definitely apply Service Pack 2for Office 2003 + applicable critical security updates. 2) Have you tried starting O...

Microsoft POS #2
I have a group of customers that I am working on setting up A bundled POS system for. I have looked at RMS and Microsoft POS. The customer's are small bulk food stores. They package all of the bulk food in various containers and weigh it with a Hobart scale producing a label with an system 2 price enbedded barcode. These are UPC A formats. They are for the most part simple single store installs and donot require the complex RMS system. I have setup the Microsoft POS version 2.0 and found it will work perfect for these customers. The only problem when you programed the system you l...

Rollup 2 and Office 2007
I already have Roll Up 1 and the Office 2007 compatibility patch installed. If I now install roll up 2 will I have to reinstall the office 2007 compatibility? yes -- Regards, MS CRM Certified Professional http://microsoftcrm3.blogspot.com Chat with me on MSN / Gmail / Skype : ID Is :.. mscrmexpert@gmail.com "LLoyd" wrote: > I already have Roll Up 1 and the Office 2007 compatibility patch installed. > If I now install roll up 2 will I have to reinstall the office 2007 > compatibility? ...

move cell contents
Is there a way to move a cell contents to another cell with a formula. ex: if a5="Name" then move g5 to j5? Also, I am using =INDEX(Sheet1!B3:B12,INT((RAND()*10)+1),1) to pick random names from a list. I have the formula in different place pick random names from different list. This does work, but I have different list with some of the same names and with the random pick I do not want the same name to appear. -- Thanks for any and all help. Davidl Hi David a formula can only affect the cell it is in, it can't move or change another cell for this you need some code ...

XCH Error 3092, OAB replication
I am getting error 3092 for OAB in Exchnage 2003 (migrated from 5.5) "Error 1129 occurred while processing a replication event. Folder: (3-8) NON_IPM_SUBTREE\OFFLINE ADDRESS BOOK\EX:/o" Tried to delete offilne addressbook and recreate but error has not stopped. Any help will be a great help on where to look to get rid of this issue. Thanks ...

Error Generating the Offlice Address Book
I have a mixed site with 3 5.5 server and 4 2003 servers. I installed 2003 SP1 a few weeks back and since then I'm having an issue generating my Offline Address Book. Here the event log messages I'm getting. Event ID 9331: OALGen encountered error 80040107 (internal ID 501023d) accessing the public folder store while generating the offline address list for address list '/'. - Default Offline Address List For more information, click http://www.microsoft.com/contentredirect.asp. Event ID 9335: OALGen encountered error 80040107 while cleaning the offline address list public ...

Highlighting cells #2
Excel 2007 sp1 with vista 32 business sp1 Background: When you highlight multiple non-contigious cells (i.e. hold the control key down and select several cells that are not connected) Excel highlights the selected cells in light blue. Problem: This light blue does not show at all on many projectors. In some case you can adjust the color temp and this helps. We do hundreds of presentation in North America each year and can not control what projection equipment we will be using. Requested solution: I would change the light blue background that is applied to selected cells to some other colo...

Lookup based on criteria in 2 columns
Hi, I am trying to use a vlookup or other function to return the value in the amount column based on the location and date. Here is a sample of my data: Location Date Amount 101 9/15/8 10 101 9/16/8 20 101 9/17/8 15 102 9/15/8 50 102 9/16/8 75 102 9/17/8 67 For example if I wanted to return the amount for location 102 on 9/15/8, what formula would I use? I tried using variations of vlookups but had no luck. Thanks, =SUMPRODUCT(--(A2:A50=102),--(B2:B50=DATE(2008,9,15)),C2:C50) -- Regards, Peo Sjo...

Customized Toolbar RestoreState() fails if it has only 1 button
This issue happens only when the numbers of buttons in the tool bar is "1". Thats is, the user launches the customize toolbar dialog and removes all but 1 tool bar button. I have multiple Tool bars which I persist on application close and restore on application load. The SaveState() works fine as I notice the value "55 81 00 00" saved if only 1 button is left in the Tool bar. Here is the code for the RestoreState for (int i = 0; i < m_ToolBars.GetSize(); i++) { HKEY hSecKey = AfxGetApp()->GetSectionKey("Tool Bars"); if (hSecKey == NULL) break; CS...

Looking for XPathReader 1.1
Where is XPathReader 1.1 available for download? I have 1.0 and found the 2005 MS announcement for 1.1 but the link was for godotnet which no longer exists. Nothing shows up in a search at the MS download center or Google. Bill ...

Store Operations crashes when viewing journal (F4) on register 2.
We have two registers, register 1 is the main machine where the database is located and register 2 is networked into it. Whenever you try to view the journal (F4) on register 2, the program crashes and gives this message just before closing: Run-time error '-2147417848 (80010108)': Automation error The object invoked has disconnected from its clients. Does anyone have any suggestions as to what the problem may be? Any help would be greatly appreciated. Install a default windows printer on register 2 - even if it's just something like the print to fax or MS Office Document...

if cell starts with characters formula
Hi I need to count cells in a column starting with certain characters. each cell's data varies in length. I have tried with @countif( but does not work if the cell contains other characters after the "prefix". eg. row 20 cell 5 apples row 21 cell 5 apples red row 22 cell 5 apples green row 23 cell 5 plums green row 23 cell 5 plums purple totals required for apples = 3 (regardless of colour) total required for plums = 2 (regardless of colour) @countif(C20:c30,"plums") gives answer of 1 require answer of 2 @countif(C20:c30,&quo...

Using part of a cell in a chart title
I have a chart which should get a title. However, this should be partly be used from a cell e.g. "counted with 5%" 5% should be taken from the cell and used in the title. Is this possible? Hi, Yes it's possible but all of the chart title needs to be in the cell. So you may need to use a helper cell and concatenate text and value. http://www.andypope.info/tips/tip001.htm Cheers Andy -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info "Nicole" <Nicole@discussions.microsoft.com> wrote in message news:5CB7A971-AA7F-4C34-BB42-7DC283AA2958@micro...

visible cell only
I'd like to use the PERCENTILE function in a list that has been autofiltered and get the results based only on the visible cells. I've used SUBTOTAL in order to get count, average, min and max. But I need to get the .25 and .75 percentile figures for the filtered data (visible cells only). I've scoured these forums. I've scoured the web. I've found some vba code that was supposed to select only visible cells but it doesn't work for me. I posted last week in the programming section of these forums (and again this morning) but got no reply. I figure...

Error: Invalid byte was found at byte index 63.
Does anyone know what this means: "Invalid byte was found at byte index 63. " If yes, please help. Apogee Apogee wrote: > Does anyone know what this means: > > "Invalid byte was found at byte index 63. " That means exactly what it says: At index 63 XML parser found a byte, which is invalid either according document's encoding or is forbidden in XML documents at all (see list of allowed in XML characters at http://www.w3.org/TR/2000/REC-xml-20001006#charsets) -- Oleg Tkachenko http://www.tkachenko.com/blog Multiconn Technologies, Israel ...

Set request parameters for web services
My .net application is to consume a Java web services exposed using AXIS. The web service will extract the user name and password to perform some custom authentication. /** Java **/ userId = hReq.getParameter("wsUserName"); password = hReq.getParameter("wsPassword"); So my ASP.net application will need to set the user id and password to be passed as a HTTP request parameters upon calling the java web service. I have added a web refernce to this web service inside my .net application. But i can't seems to find any methods or parameters to set the request parameters...

what's the formula for adding symbols in cells?
I have a chart that has blank info in the legend. I want to add an * to indicate something, but just inserting a symbol doesn't work. Any ideas? Thanks. Debi - To add information to the legend, you need to add to a series name. Right click on the chart, select Source Data from the pop up menu, click on the series tab, select a series, and either type something in the name box, or click in it and select a cell with the mouse. - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services http://PeltierTech.com/Excel/Charts/ _______ Debi wrote: > I have a chart tha...

Invalid XML error when I open customization setting
I have a problem when I try to open customization setting after I import an entity. The system errored "Invalid XML" "The XML passed to the platform is not well-formed XML". Please recommend how to resolve this problem. Thanks. ...

Linker Error after upgrade from VC7.1
Hello all, After upgrading a VC7.1 project to visual studio 2005, it failed to build in the release configuration with the follwoing error : 1>nafxcw.lib(winocc.obj) : error LNK2005: "public: class CWnd * __thiscall CWnd::GetDlgItem(int)const " (?GetDlgItem@CWnd@@QBEPAV1@H@Z) already defined in InstallDlg.obj The debug build works fine. The project uses MFC in a static library. Well, after doing some research, it seems that this one is tied to the fact that in a release configuration, _AFX_ENABLE_INLINES is defined, so inline functions are embedded in the .obj file. Sure there...

Unexpected error message on closing an Excel file
Suddenly I am getting the following message when I try to close a workbook: "Your formula contains an invalid external reference to a worksheet. Verify that the path, workbook, and range name or cell reference are correct, and try again" The mysterious thing is that it does not happen consistently and that, after I click OK after the above message, I can still save the file. What might be the cause of this error message and can the "invalid reference" be tracked down using one of the utility add-ins such as J. Walkenbach's PUP? If it only happens when you close ...

2 register ruinning together on one z report
Is this possible, to have two registers running on one z report ? We have a small store and would like to setup a second register as a backup, temporary addition ( during rush hours) Since we are a small show i do not need to have a separate register reports. Can two registers ring up all sales together as one ? How can i set this up ? No, you can't do that. You might be able to use the Register Analysis report available in SO Manager Utilities/Crystal Reports to get something close to a single Z though. Glenn Adams Tiber Creek Consulting http://www.tibercreek.com glenn@tibercreek.c...

Setting MDI Parent Size To Fit Around A Child Form
Hi, How do you set the client size of an MDI parent to fit around a child form? Breakpoints in the constructor and load event handler show the child size to be already modified to fit into the parent; the child's size does not match what shows in the Designer. I suppose the real question might be how do you determine the size of the child window or keep the parent from changing it first? Thanks, Gary What you're asking for is a little backwards, but I'm sure you have your reasons. At any rate, these are the properties you will want to investigate: ...

Please ignore #2
Testing a posting problem -- Jim Bunton ...

DNS Error on Exchange
I am getting the following error on my Exchange server. What is my problem? Thanks. Event Type: Warning Event Source: smtpsvc Event Category: None Event ID: 2012 Date: 1/28/2005 Time: 12:01:53 PM User: N/A Computer: PUMA Description: SMTP could not connect to the DNS server '24.220.0.11'. The protocol used was 'UDP'. It may be down or inaccessible. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. Data: 0000: d5 04 00 00 Õ... Is that a DNS server that's configured on your Exchange box? It shoul...

How do I merge cells with multiple data values?
I've tried highlighting the two cells which are in the same row. It suggested that I format and align. Both of which I've tried. I keep getting the same error message, "The selection contains multiple data values. Merging into one cell will keep the upper-most data only." I need to make the cells one with all my information. Is this possible? Not knowing what you want to do, let me make a suggestion. Put all your data into the first cell and leave the second cell empty. Select both cells. Click on Format - Cells - Alignment tab. In the "Horizontal" b...