Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Copying above cells in cells directly below as default values

13 views
Skip to first unread message

Edward S

unread,
Jun 20, 2003, 2:40:05 AM6/20/03
to
How can I copy the above cells in the 1st 3 columns in the cells
directly below when I move to a new line. For eg The 1st 3 Columns
"A"(ContractNo), "B"(ContractRef) and "C"(WRNo). I want to
programatically be able to copy the contents of the cells directly
above in the cells directly below, every time I move to a new line.
Can someone point in the right direction

Ed
PS:
Ofcourse I have other columns to the right, but the 1st 3 cells on a
new line usually repeat, unless its a new contract No.)

Chris F

unread,
Jun 20, 2003, 10:02:33 AM6/20/03
to
How about an if statement.

If (a1<>"",a1,"")

Instead of the first 'a1' you could point it to one of the data cells to the
right and then it would only fill in the next line if you started to enter
other data.

"Edward S" <soar...@qatar.net.qa> wrote in message
news:57703a81.03061...@posting.google.com...

David McRitchie

unread,
Jun 20, 2003, 1:32:56 PM6/20/03
to
Hi Edward,
Take a look first at my
Insert a Row using a Macro to maintain formulas
http://www.mvps.org/dmcritchie/excel/insrtrow.htm
for some further insight, though it doesn't address your
specific question..

From what you describe you want an Event macro, which are
described on and has installation instructions
http://www.mvps.org/dmcritchie/excel/event.htm
However, I will provide what you need below. As you can see
Event macros are installed differently.

Right-click on worksheet tab, view code, plop this code in,
there should only be a single Option Explicit statement and
you should already have it upon view code..

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row < 3 Then Exit Sub
If Target.Column <> 1 Then Exit Sub
If Not IsEmpty(Target) Then Exit Sub
Application.EnableEvents = False 'should be part of Change macro
Target.Value = Target.Offset(-1, 0).Value
Target.Offset(0, 1).Value = Target.Offset(-1, 1).Value
Target.Offset(0, 2).Value = Target.Offset(-1, 2).Value
Application.EnableEvents = True 'should be part of Change macro
End Sub

If you have formulas in any of those three cells you might want to
take a look at the insrtrow.htm page, because you can't just
change .value to .formula in the above..

HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Edward S" <soar...@qatar.net.qa> wrote in message news:57703a81.03061...@posting.google.com...

Edward S

unread,
Jun 21, 2003, 5:05:16 AM6/21/03
to
"David McRitchie" <dmcri...@msn.com> wrote in message news:<uQqZ3J1N...@TK2MSFTNGP12.phx.gbl>...

Thanks Dave it helped

Edward

0 new messages