ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Putting a formula in the first empty cell in a row (https://www.excelbanter.com/excel-programming/382046-putting-formula-first-empty-cell-row.html)

timmulla

Putting a formula in the first empty cell in a row
 
Can anyone help me with code that can put a formula in the first empty cell
in a row? Basically, I want to replace the B3 in the following formula so
that it will put the formula in the first empty cell in row 3. I'm trying to
make the following formula dynamic.

Range("B3").FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"


any help would be appreciated.

--
Regards,

timmulla

Dave Peterson

Putting a formula in the first empty cell in a row
 
Can you find the first open cell by starting at the far right and doing the
equivalent of End|leftArrow.

If yes

dim NextCell as range
with activesheet
set nextcell = .cells(3,.columns.count).end(xltoleft).offset(0,1)
end with

nextcell.formular1c1 = ....



timmulla wrote:

Can anyone help me with code that can put a formula in the first empty cell
in a row? Basically, I want to replace the B3 in the following formula so
that it will put the formula in the first empty cell in row 3. I'm trying to
make the following formula dynamic.

Range("B3").FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"

any help would be appreciated.

--
Regards,

timmulla


--

Dave Peterson

Don Guillett

Putting a formula in the first empty cell in a row
 

LR=cells(1,"b").end(down).row+1
or you may like this better
LR=cells(rows.count,"b").end(up).row+1

Range("B" & lr).FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"

--
Don Guillett
SalesAid Software

"timmulla" wrote in message
...
Can anyone help me with code that can put a formula in the first empty
cell
in a row? Basically, I want to replace the B3 in the following formula so
that it will put the formula in the first empty cell in row 3. I'm trying
to
make the following formula dynamic.

Range("B3").FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"


any help would be appreciated.

--
Regards,

timmulla




JLGWhiz

Putting a formula in the first empty cell in a row
 
Don, he wanted the first empty in row 3, so instead of:

LR=cells(1,"b").end(down).row+1

Try this:

LC = Cells(3,1).End(xlToRight).Column + 1
Cells(3, LC) .FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"



"Don Guillett" wrote:


LR=cells(1,"b").end(down).row+1
or you may like this better
LR=cells(rows.count,"b").end(up).row+1

Range("B" & lr).FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"

--
Don Guillett
SalesAid Software

"timmulla" wrote in message
...
Can anyone help me with code that can put a formula in the first empty
cell
in a row? Basically, I want to replace the B3 in the following formula so
that it will put the formula in the first empty cell in row 3. I'm trying
to
make the following formula dynamic.

Range("B3").FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"


any help would be appreciated.

--
Regards,

timmulla





Don Guillett

Putting a formula in the first empty cell in a row
 
Thanks

--
Don Guillett
SalesAid Software

"JLGWhiz" wrote in message
...
Don, he wanted the first empty in row 3, so instead of:

LR=cells(1,"b").end(down).row+1

Try this:

LC = Cells(3,1).End(xlToRight).Column + 1
Cells(3, LC) .FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"



"Don Guillett" wrote:


LR=cells(1,"b").end(down).row+1
or you may like this better
LR=cells(rows.count,"b").end(up).row+1

Range("B" & lr).FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"

--
Don Guillett
SalesAid Software

"timmulla" wrote in message
...
Can anyone help me with code that can put a formula in the first empty
cell
in a row? Basically, I want to replace the B3 in the following formula
so
that it will put the formula in the first empty cell in row 3. I'm
trying
to
make the following formula dynamic.

Range("B3").FormulaR1C1 = "=SUM(R[1]C[-2]:R[65535]C[-2])"


any help would be appreciated.

--
Regards,

timmulla








All times are GMT +1. The time now is 08:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com