Adding to rows - sign issue??

G

Guest

Hi

I'm adding two rows with

with ActiveSheet
Range("D12").formula ="B12+C12"
Lrow = Range("C" & Rows.count).end(xlup).row
Range("D12:D" & Lrow).filldown
End With

it doesn't work when I have a negatif value. It's adding like if it was a
positif value. I changed the category of the row to number but when I'm
running that macro then it sends back the category to General. I'm biginning
in excel can you tell me what to do ?

My second question is when I have to add a $ in my macro like example
($A1:$B1)? Do you have a web site where I can learn about it?

Thanks
Jack
 
G

Guest

with ActiveSheet
Range("D12").formula ="=B12+C12" ' add an equal sign
Lrow = Range("C" & Rows.count).end(xlup).row
Range("D12:D" & Lrow).filldown
End With

for building a formula that uses $,
In Excel help, look at absolute and relative references.

As an argument to the Range object, you never need to use $.
 
G

Guest

Thanks Tom,
It works but only for positive values. If I have -555+3 the value will be
558 instead of -552. Do you know what I have to do to keep the row in integer
instead of general category?
 
G

Guest

B12: -555
C12: 3

Range("D12").formula ="=B12+C12"

gave me -552 in D12

format the cell to display an integer.

If you want it to actually hold an integer then change the formula to


Range("D12").formula ="=Round(B12+C12,0)"

or

Range("D12").Formula ="=Trunc(B12+C12,0)"

depending on what you want.
 
G

Guest

Thanks Tom, it works!

Tom Ogilvy said:
B12: -555
C12: 3

Range("D12").formula ="=B12+C12"

gave me -552 in D12

format the cell to display an integer.

If you want it to actually hold an integer then change the formula to


Range("D12").formula ="=Round(B12+C12,0)"

or

Range("D12").Formula ="=Trunc(B12+C12,0)"

depending on what you want.
 

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