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 / May 2008

Tip: Looking for answers? Try searching our database.

cells function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Raul Sousa - 19 May 2008 15:11 GMT
The resulto of the code
   ActiveCell.Formula = "=" & (Cells(11, Sheets.Count + 1))
is : =
But, I need it to be equal to :
= D11, or E11, depending on the number of sheets
What am I doing wrong?
Rick Rothstein (MVP - VB) - 19 May 2008 15:27 GMT
Your question is not entirely clear to me. Are you looking for this?

ActiveCell.Formula = "=" & Chr(65 + Sheets.Count) & "11"

Rick

> The resulto of the code
>    ActiveCell.Formula = "=" & (Cells(11, Sheets.Count + 1))
> is : =
> But, I need it to be equal to :
> = D11, or E11, depending on the number of sheets
> What am I doing wrong?
Joel - 19 May 2008 15:29 GMT
A formula has to look lie it would on a worksheet such as "=D11"

You can modify your code like this

ActiveCell.Formula = "=" & (Cells(11, Sheets.Count + 1).address)

or
ActiveCell.Formula = "=K" & (Sheets.Count + 1)

> The resulto of the code
>     ActiveCell.Formula = "=" & (Cells(11, Sheets.Count + 1))
>  is : =
> But, I need it to be equal to :
>  = D11, or E11, depending on the number of sheets
> What am I doing wrong?
JW - 19 May 2008 15:37 GMT
> A formula has to look lie it would on a worksheet such as "=D11"
>
[quoted text clipped - 13 lines]
>
> - Show quoted text -

Joel, that last option wouldn't work.  The "11" in the Cells function
is refering to the row number, not the column number.
JW - 19 May 2008 15:30 GMT
On May 19, 10:11 am, Raul Sousa <RaulSo...@discussions.microsoft.com>
wrote:
> The resulto of the code
>     ActiveCell.Formula = "=" & (Cells(11, Sheets.Count + 1))
>  is : =
> But, I need it to be equal to :
>  = D11, or E11, depending on the number of sheets
> What am I doing wrong?

Right now, you are basically saying that you want the formula to equal
the value of that cell.  What you need it to do is equal the address
of that cell.

For absolute references, use
ActiveCell.Formula = "=" & Cells(11, Sheets.Count + 1).Address

Or use this if you do not want absolute references
ActiveCell.Formula = "=" & Cells(11, Sheets.Count + 1).Address(False,
False)
Raul Sousa - 19 May 2008 16:05 GMT
Thank you.
It was very clear.
I need to use. adress if I need the cell's adress.

> On May 19, 10:11 am, Raul Sousa <RaulSo...@discussions.microsoft.com>
> wrote:
[quoted text clipped - 15 lines]
> ActiveCell.Formula = "=" & Cells(11, Sheets.Count + 1).Address(False,
> False)
luis_excelkid - 19 May 2008 15:43 GMT
Hi Raul,

The problem is the "formula" is only taken the "=" symbol and not the
reference to the "Cells(11....." because "Cells(11...." represents a value,
for example, watch my lines and this it works.

Sub prueba()
   aux = "B1"
   Range("A1").Formula = "=" & aux
End Sub

yo just need to find a way to transform the "Cells(11...." to a text string
it represents the cell you are referencing for... if i find a way i will let
you know...
 
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.