Need Help Immediately

P

padmaja

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
 
B

Bernie Deitrick

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
 
M

merjet

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
 
B

Bernie Deitrick

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
 
M

merjet

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
 
T

Tushar Mehta

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
 

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