cells function

R

Raul Sousa

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?
 
R

Rick Rothstein \(MVP - VB\)

Your question is not entirely clear to me. Are you looking for this?

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

Rick
 
J

Joel

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)
 
J

JW

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)
 
J

JW

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)





- 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.
 
L

luis_excelkid

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...
 
R

Raul Sousa

Thank you.
It was very clear.
I need to use. adress if I need the cell's adress.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top