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
875 Views

Similar Articles

[PageSpeed] 18

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:

setting up new outlook mail account
i can not set up a new account on my outlook, i keep saying establish network connection with a correct sign but searching for my mail account shows X can you please advise Are you trying to setup a POP3 mail account or an Exchange account? Also, what version of Outlook are you using? "rashid" <rashid@discussions.microsoft.com> wrote in message news:C59D04C0-C1C9-4BD1-AE00-2009D25B221D@microsoft.com... > i can not set up a new account on my outlook, i keep saying establish > network > connection with a correct sign but searching for my mail account shows X > ...

cannot send attachments #2
I also suddenly cannot send attachments - probably about 3 weeks now - my ISP says it is an Outlook problem. Anyone know what is oging on? What version of Outlook, including the number? TOOLS | HELP | ABOUT MICROSOFT OUTLOOK Have you updated lately? Do you get any errors or messages? -- Nikki Peterson [MVP - Outlook] "klk" <anonymous@discussions.microsoft.com> wrote in message news:044701c3975f$ccc8b9e0$a401280a@phx.gbl... I also suddenly cannot send attachments - probably about 3 weeks now - my ISP says it is an Outlook problem. Anyone know what is oging on? ...

How do I set up an argument which asks for multiple criteria
I am trying to use an argument that asks for one of three criteria (2345P, 8319T, or 7026J) in cell C108, and if it finds it, enters the amount of yet another cell, G108 into cell K108, and if not enters 0 into cell K108. It seems there are too many arguments for the "if" argument, and I can't seem to get the "lookup" argument to work either. Is there another argument I should be working with? Thanks -- Diver Try: =IF(OR(C108="8319T",C108="2345P",C108="7026J"),G108,0) "bj" wrote: > try in K108 > =if(or(c108=&qu...

Inserting time inside cell
I use Office 2003 Excel Win XP Can someone tell me how to insert time: hours, minutes and seconds inside a cell? sn hi, hh:mm:ss or 12:12:12 also see Format>cells>number tab. scroll down left to custom. scroll down right to see other formats. regards FSt1 "Sachi Noma" wrote: > I use Office 2003 Excel Win XP > > Can someone tell me how to insert time: hours, minutes and seconds inside a > cell? > > sn > > Hi Sachi, Not sure if this is what you are looking for but if you hit ctrl+; in a cell it will put the current date in that cell, i...

Javascript Error opening threads
In Windows XP General Discussions, when I click on a thread to expand it, it says 'loading' but there is a 'javascript 0' error message on the left side of the status bar. When I attempt to refresh the page, it says 'service temporarily unavailable.' Anyone else have this issue? What's the fix? The issue is that the newsserver for the web-interface is horked /again/. The fix is to access this and other MS newsgroups in your newsreader (e.g., Outlook Express). Setting up Outlook Express to access Microsoft newsgroups http://www.michaelstevenstec...

OWA Set Rule problem
I have successfully install the Exchange 2003 with SP1 in the Windows Server 2003. Anything alright exclude the rules function in OWA. I try to set the rules from any then "move to" or "copy to" specify folder are no problem, but "forward to" other email address, its don't work. I try to input the email address in the contact and then select from the contact, but the result also don't work. The rules can save and I can receive the incoming email in the Exchange 2003/Outlook or OWA, but it don't forward to my specify email address. I try to...

email fonts #2
Dear all Why do some of the emails I receive come over in Courier? And when I reply I can't change the font. I am on Outlook 2007. EGB Are you receiving then sending email in plain text mode ? kev "egb" <egb@nospam.co.uk> wrote in message news:OqK1qILtHHA.1204@TK2MSFTNGP03.phx.gbl... > Dear all > > Why do some of the emails I receive come over in Courier? And when I > reply I can't change the font. I am on Outlook 2007. > > EGB > > > > > ...

How do I set the 'Set Synchronizing Client' field
We have a number of outlook clients using CRM that have the 'Set Synchronizing Client' select box greyed out. We need to tick them so that they are able to synchronize tasks etc. Can any one help me find out why these are greyed out and then set them so that they can synchronize thanks In my experience, that checkbox is always greyed out for the first install that is performed for a user. The only time that checkbox becomes active is if a second copy of CRM is installed for a user who already has CRM installed on another PC.... Normally the box is checked and grey. If that is...

layout help-creating 2 pages on 8 1/2 x 11 paper for booklet
I am new to Publisher, so bear with me.... I am trying to create a booklet using 8 1/2 x 11 paper in positioned in landscape position. I would like to get 2 pages on one piece of paper, but with the text in a portrait position, if that makes sense. Can anyone guide me? Thanks. -- Lauren When you setup your publication as a booklet, the pages are presented in the correct order automatically. The half pages will be portrait. Have you tried to setup a booklet? If you have, what problems are you experiencing? -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.or...

Sending error #3
Using Outlook 2002. I'm getting lots of sending errors - code 0x800CCC78 - with Outlook apparently trying to send email from using my Compuserve account but failing. That's not surprising as my Outlook isn't set up to send from Compuserve. Trouble is I can't find any messages that it's trying to send. Nothing in Outbox or anywhere else that I can see. Any ideas where/how I can zap the offending emails? Bryan Hello Bryan, this error accours, when the SMTP needs an authentification. Please activate Server need to authentifacate under your Account Options. "Brya...

How do I make a cell appear empty when the formula = 0?
If the answer to the formula is 0, how can I make it just show the cell as empty instead of actually putting a 0 in the cell? =if(yourformulahere=0,"",yourformulahere) t1202 wrote: > > If the answer to the formula is 0, how can I make it just show the cell as > empty instead of actually putting a 0 in the cell? -- Dave Peterson In say A1 =IF(B1+B2=0,"",B1+B2) Regards, Alan "t1202" <t1202@discussions.microsoft.com> wrote in message news:FE8FD529-9AA3-484D-BEE1-40332E97A2A9@microsoft.com... > If the answer to the formula is 0, how can I ...

range of dates schedule
I am trying to make a spreadsheet to show me when and how much a too was checked out of my work. i am inputing the dates and i would like the spreadsheet to tell me ho many days in each month it worked. please help, i have been working on this for 2 days -- Message posted from http://www.ExcelForum.com With your "Start date" in A1 and your "Finish date" in B1, put the following formula in C1 and format the cell for Number with no decimal places =B1-A1 Vaya con Dios, Chuck, CABGx3 "Coy Bruner >" <<Coy.Bruner.12gi7n@excelforum-nospam.com> wrote ...

Text and ranges.
How do you wrap text within a range? Hi not really sure what you're trying to do. Could you give an example? -- Regards Frank Kabel Frankfurt, Germany "jim252627" <jim252627@discussions.microsoft.com> schrieb im Newsbeitrag news:4D206631-71FA-48BE-82B4-3624D58A987D@microsoft.com... > How do you wrap text within a range? For example, if I am designing a form and one of the fields of the form requires text, the command would be "wrap-text" within the cell format command. However, if many columns are narrow because of fields (ranges) established above or ...

How to set backcolour
Hello All I have a continuous form containing a number field (long integer) called [v_colour]. This field contains the number of a certain colour - as per the numbers that are used in the format properties for back colour etc. I would like to set the back colour for the form's [v_colour] text box to be the value of the field: e.g. If the value of [v_colour] in the first record is 255, I want the back colour of the textbox for that record to be bright red. I tried this as the OnLoad event for the form: [v_colour].backcolour = [v_colour].value .... but this resulted in the back colour of...

Error message
Converting from 2003 to 2007 excel and using pivot tables with data from a database. I attempt to link in the table from access I get this error message: "You cannot choose a connection file that is incompatible with the existing connection". What does this mean and how do I correct? Any help is greatly appreciated as I have several pivotables that need converting. Thank you. ...

How to keep a cell empty at the same time formula embedded?
Can we have an empty cell but formula embedded in that cell. A cell cannot be both "empty" and contain something...........you can however, put a formula there that will display a blank cell according to the conditions of it's calculations........... =(IF(A1>5,A1,"")......will display a blank cell if A1 is 5 or less Vaya con Dios, Chuck, CABGx3 "vic_dic" <vic_dic@discussions.microsoft.com> wrote in message news:A590D8A6-7E86-49B7-AA9A-12DE213E670C@microsoft.com... > Can we have an empty cell but formula embedded in that cell. What are you...

Applying Percent Decrease Across Set Periods
I have a column which includes dates when items were purchased. I have used the DATEDIF function to find the number of years between that date and today's date. I now want to decrease the purchase amount 10% for every year calculated via the DATEDIF function. Any ideas, is this possible, why can't I think...? -- Hunt&amp;Peck ------------------------------------------------------------------------ Hunt&amp;Peck's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=32961 View this thread: http://www.excelforum.com/showthread.php?threadid=527873 ...

Deposit on Sales Order #2
Let's say you have a sales order with 2 lines on it. The first line is for $10,000 and the second is for $40,000. This is a new customer so you ask for 50% deposit. Customer pays $25,000 so you put this amount on the invoice. Now you only invoice them for the first line. The invoice will print with a -$15,000 total because $10,000 - $25,000=$15,000. Now you come along and want to print an invoice for the second line. The deposit amount does not print on this second invoice. This is a problem because the customer is expecting to see a second invoice with a balance due of $0.00. Does ...

Copy formula for ranges from diff sheets #2
Unfortunatley then i have to go to every sheet, copy and paste special (transpose) What I need is some sort of formula that will copy the same range fro _all_sheets_ and then paste special (transpose) on to the referenc sheet. ? -- Berni ----------------------------------------------------------------------- Bernie's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1457 View this thread: http://www.excelforum.com/showthread.php?threadid=26197 Hi not possible with a formula. This would require VBA >-----Original Message----- > >Unfortunatley then i h...

Set Regional Settings but not Language
Hi I have a multi-language APP en-US, es-ES, it-IT I usually change Languages and Locales by using the CultureInfo to switch Languages System.Globalization.CultureInfo myCI = new System.Globalization.CultureInfo("es-ES"); My issue is - what if the user wants to View App in english and use the Regional Options on a PC in say Spain ??? If I change the CultureInfo to en-US then they can view APP in English ( English satelite assemblies) but date and numbers will be in US format If I change the CultureInfo to es-ES then date and numbers will be in Spain forma...

x Bar and R chart
Has anyone created an x-Bar and R chart in excel. Uncle bob: I entered XBar Chart Excel and found over 9,200 references. So there is a lot out there for you to look at. There are a number of commercial add-ins if you are undertaking a major Statistical process Control (SPC) program. On the other hand, there are dozens of free downloads if your are looking for "how to" information. I have put a simple control chart "how to" on my site that may help to get you started. http://processtrends.com/pg_charts_control_chart.htm .... Kelly koday@processtrends.com &qu...

Search cells with many numbers a few numbers?
In Excel, I'd like to search cells which have many numbers in each, they are separated by spaces. I'd like to look in the cells for a few numbers. The logic statements do not seem to work. How do I do this? ...

Work Hours setting excludes specified hours from Scheduling
I am miffed by this problem. I specify a work hour schedule for a user. When I schedule a CRM User as a Resource for a Service in Scheduling of a Service Activity with Requested Time of ASAP and click Find Available Times, the values for Avilable Times returned are outside of the Work Hours I specified for the user and not within the work hours. When I drill into the Work Hours for this User, the Calendar view shows Cross Day rather than 8:00AM - 5:00PM I speciied for work hours and editing the hours reveal the correct hours in the Work Hours. What gives? Never mind. Figured out w...

Reading Pane Settings
I did a search for an answer to this question and have not found one. If I missed an answer already posted, please direct me to the right place. I have Outlook 2007 and set up the "right" reading pane for my e-mail. Now when I go to my calendar it is set up the same way - calendar on the left (same size as the inbox) and then there is a blank space to the right that is the size of the reading pane/preview. To the right is the to-do bar (which I have no problem with). I don't know why there is a reading/preview pane on the calendar when there is nothing to preview, and I...

Outlook "Arrange By" option does not retain its setting
In outlook 2007, I use a custom view for my inbox, and I have the Group By option checked to"Automatically group according to arrangement." This has been workn flawlessly until today, when I realized Outlook did not like a particular mouse click; perhaps I clicked on the border of two options or some other anomoly that caused the window toflash once. The end result was that my Arrange By option changed to "From" when I had previously set it to "Conversation." Now, whenever I hange it backto "Conversation," leave the inbox and come back, ...