Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

How to: assign a value to a cell without selecting the cell first

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George Furnell - 23 Jan 2006 13:51 GMT
Hi,

Its clear that I am still a newbie...

In VBA, how do I assign a value to a cell with out first selecting the cell?
In pseudo code I would describe it as "Assign the value 5 to the cell in
location x".

Kind regards

George
Don Guillett - 23 Jan 2006 14:02 GMT
try
cells(1,5)=5
or
range("a5")=5

Signature

Don Guillett
SalesAid Software
dguillett1@austin.rr.com

> Hi,
>
[quoted text clipped - 8 lines]
>
> George
Tushar Mehta - 23 Jan 2006 14:07 GMT
In the simplest form: Cells({row},{column}).value=5
More explicitly: Worksheets({worksheet id}).Cells({row},{column}).value=5

Signature

Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

> Hi,
>
[quoted text clipped - 7 lines]
>
> George
George Furnell - 23 Jan 2006 14:16 GMT
Thank you, thats what I was looking for.

Kind regards

George
Bob Phillips - 23 Jan 2006 14:11 GMT
Range("A1").Value = 1

It is also good practice to reference the workbook and worksheet

   With Activeworkbook
       With .Worksheets("Sheet1")
           .Range("A1").Value = 5
...
       End With
   End With

note the leading dots

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

> Hi,
>
[quoted text clipped - 7 lines]
>
> George
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.