Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Reference to cell - VBA

Hi

I'm trying to write a user defined function which references a cell in sheet
1 in my spreadsheet. Cell A10 currently has the value of 20 - how do I
reference this cell in my VBA program.

Thanks

Darryl


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Reference to cell - VBA


Try this:


Code:
--------------------
Dim n as integer
n = Sheets(1).Cells(10,1).value
--------------------


where the 10 is row number as 1 is column number (hence A10).
A more efficient a safer way of referencing cells is to give them
names. So for example in your worksheet you defined cell A10's name to
be -number- then you can use the following code.


Code:
--------------------
Dim n as integer
n = Sheets(1).Range("number").value
--------------------


This way if you were to shift cell A10 to some other location on the
sheet you will not have to change the code.

Hope this helps!


--
schoujar
------------------------------------------------------------------------
schoujar's Profile: http://www.excelforum.com/member.php...o&userid=26574
View this thread: http://www.excelforum.com/showthread...hreadid=547311

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nesting a sheet name reference within a cell reference??? Broyston Excel Discussion (Misc queries) 9 July 8th 08 08:35 PM
Changing sheet reference to cell reference TeeJay Excel Worksheet Functions 3 October 19th 07 11:50 AM
absolute cell reference A spreadsheet cell reference that does no help Excel Discussion (Misc queries) 1 January 18th 06 06:56 PM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable [email protected] Excel Worksheet Functions 2 December 11th 04 12:00 AM


All times are GMT +1. The time now is 02:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"