ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need Help Immediately (https://www.excelbanter.com/excel-programming/279220-need-help-immediately.html)

padmaja

Need Help Immediately
 
Hi,
I want to know how can we use the same formula in all the new
cells inserted, programatically in VBA.

For example:
i have a formula for the cell D1 as (A1+B1+C1)/3 .now suppose i
insert a new cell D5 i want the same formula to be there for this cell
also which should be (A5+B5+C5)/3.

Is it possible to do it programatically?

Could anyone look into this as soon as possible?

Awaiting for the reply

Regards,
Padmaja



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Bernie Deitrick[_2_]

Need Help Immediately
 
Padmaja,

Immediately after you insert cell D5, simply type Ctrl-' - the key
combination CTRL and single quote. That will copy the formula from
the cell above.

To do this automatically would require a lot of logic and coding,
since Excel doesn't have a cell insertion event.

HTH,
Bernie


"padmaja" wrote in message
...
Hi,
I want to know how can we use the same formula in all the new
cells inserted, programatically in VBA.

For example:
i have a formula for the cell D1 as (A1+B1+C1)/3 .now suppose i
insert a new cell D5 i want the same formula to be there for this

cell
also which should be (A5+B5+C5)/3.

Is it possible to do it programatically?

Could anyone look into this as soon as possible?

Awaiting for the reply

Regards,
Padmaja



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/




merjet

Need Help Immediately
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 4 And Target.Row 1 Then
If Target.Offset(-1, 0) = "" Then Exit Sub
Target.FormulaR1C1 = Target.Offset(-1, 0).FormulaR1C1
End If
End Sub

HTH,
Merjet



Bernie Deitrick[_2_]

Need Help Immediately
 
Merjet,

This event code is not triggered when a cell is inserted. The user
would need to de-select / re-select the cell to get it to work. It
would also insert a formula if the user selected the blank cell at the
bottom of the block of cells in column D.

HTH,
Bernie


"merjet" wrote in message
news:jQxhb.727948$uu5.123793@sccrnsc04...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 4 And Target.Row 1 Then
If Target.Offset(-1, 0) = "" Then Exit Sub
Target.FormulaR1C1 = Target.Offset(-1, 0).FormulaR1C1
End If
End Sub

HTH,
Merjet





merjet

Need Help Immediately
 
This event code is not triggered when a cell is inserted.

I was guessing at what Padmaja wanted. I know what
"insert a row" or "insert a column" means, but not "insert
a cell".

Merjet



Tushar Mehta

Need Help Immediately
 
Easy enough to find out what "insert a cell" does. Select any cell.
Select Insert | Cells...

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article <qczhb.722037$Ho3.175570@sccrnsc03,
says...
This event code is not triggered when a cell is inserted.


I was guessing at what Padmaja wanted. I know what
"insert a row" or "insert a column" means, but not "insert
a cell".

Merjet





All times are GMT +1. The time now is 10:34 AM.

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