PC Review


Reply
Thread Tools Rate Thread

Brackets [] possibilities ?

 
 
alainB
Guest
Posts: n/a
 
      15th May 2004
Hi,

If I want to put the number 6 in the cell A1 up to now I was doing i
this way:

Range("A1").Select
ActiveCell.FormulaR1C1 = 6

I learn from one post here that I can do it much more easily this way:

[A1] = 6

As long as I just want to put a specific value in one particular cell
should I do it this way?

Thanks

Alai

--
Message posted from http://www.ExcelForum.com

 
Reply With Quote
 
 
 
 
Frank Kabel
Guest
Posts: n/a
 
      15th May 2004
Hi
try
=Range("A1").value=6

--
Regards
Frank Kabel
Frankfurt, Germany


> Hi,
>
> If I want to put the number 6 in the cell A1 up to now I was doing it
> this way:
>
> Range("A1").Select
> ActiveCell.FormulaR1C1 = 6
>
> I learn from one post here that I can do it much more easily this

way:
>
> [A1] = 6
>
> As long as I just want to put a specific value in one particular

cell,
> should I do it this way?
>
> Thanks
>
> Alain
>
>
> ---
> Message posted from http://www.ExcelForum.com/


 
Reply With Quote
 
alainB
Guest
Posts: n/a
 
      15th May 2004
Thanks,

But wy not [A1] = 6 ?

Still much shorter!

Alai

--
Message posted from http://www.ExcelForum.com

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      15th May 2004
Alain,

In some MS documentation (I forget the URL, probably somewhere in
MSDN), it was noted that using the [] syntax is significantly
slower than using the Range() syntax. I suspect, but don't know
for a fact, that everything inside the [] is unknown to the
compiler at compile time, and has to be resolved at run time.
This causes extra code to be generated at compile time and
executed at run time.

You should never use the syntax in your first example:

> Range("A1").Select
> ActiveCell.FormulaR1C1 = 6


There is no reason to Select the range before operating upon it,
and Select is an expensive operation. Instead, combine the two
lines in to a single line of code like

Range("A1").Value = 6

Performance issues aside, whether to use the [] syntax is a
matter of personal taste. I don't like it (I'm not sure why I
don't like it, but I don't), so I always use the Range() syntax.
If you read the posts of the professional developers in this
newsgroup, you'll find that nearly everyone uses the Range()
syntax over the [] syntax. However, you are free to develop a
coding style that suits you. Whichever you choose, be consistent;
don't mix and match reference styles.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"alainB >" <<(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> Hi,
>
> If I want to put the number 6 in the cell A1 up to now I was

doing it
> this way:
>
> Range("A1").Select
> ActiveCell.FormulaR1C1 = 6
>
> I learn from one post here that I can do it much more easily

this way:
>
> [A1] = 6
>
> As long as I just want to put a specific value in one

particular cell,
> should I do it this way?
>
> Thanks
>
> Alain
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>



 
Reply With Quote
 
Rob van Gelder
Guest
Posts: n/a
 
      15th May 2004
You could do it this way and it would be faster than doing .Select

Range("A1").Value = 6 is faster than [A1] = 6 though.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"alainB >" <<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> If I want to put the number 6 in the cell A1 up to now I was doing it
> this way:
>
> Range("A1").Select
> ActiveCell.FormulaR1C1 = 6
>
> I learn from one post here that I can do it much more easily this way:
>
> [A1] = 6
>
> As long as I just want to put a specific value in one particular cell,
> should I do it this way?
>
> Thanks
>
> Alain
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>



 
Reply With Quote
 
alainB
Guest
Posts: n/a
 
      15th May 2004
Thanks Chip and Rob!

Alai

--
Message posted from http://www.ExcelForum.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using More than 7 possibilities in a formula saschmeling Microsoft Excel Programming 2 24th Apr 2008 02:14 AM
Conditional w/ three possibilities MathDoctor Microsoft Excel Misc 4 11th Jun 2005 03:45 PM
If Function Possibilities rheller Microsoft Excel Discussion 2 7th Jun 2005 08:12 PM
Possibilities Stephanie Microsoft Access Security 0 1st Mar 2004 07:29 PM
Datagrids... the possibilities?? Mike Fellows Microsoft VB .NET 1 29th Sep 2003 05:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:47 AM.