code to Copy cells from the above row.
Hello Everyone,
I need a code for a excel sheet. If you press the Enter on Column G, And the below row is completely empty (I mean all the cells), Copy Column A B C D E from the above row (the Row that you were before pressing the Enter) to the new row (the below Row, Row that you are in after pressin the Enter) and Column F should be the selected cell. Big thanks in advance. |
Fernando
The macro you need is a Worksheet_Change event macro and must be put in the sheet module of the sheet in which you want this to happen. Note that this macro will fire upon a change to the contents of any cell in column G, not just when you hit Enter with the active cell in Column G. If you want this to fire when you simply select a cell in column G, then you need a Worksheet_SelectionChange event macro. The macros is below. I am also sending you a small file with that macro in the right place. HTH Otto Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count 1 Then Exit Sub If Target.Column < 7 Then Exit Sub If Application.CountA(Range(Cells(Target.Row + 1, 1), Cells(Target.Row + 1, 256))) = 0 Then Target.Offset(, -6).Resize(, 5).Copy Cells(Target.Row + 1, 1) Target.Offset(1, -1).Select End If End Sub "Fernando" wrote in message om... Hello Everyone, I need a code for a excel sheet. If you press the Enter on Column G, And the below row is completely empty (I mean all the cells), Copy Column A B C D E from the above row (the Row that you were before pressing the Enter) to the new row (the below Row, Row that you are in after pressin the Enter) and Column F should be the selected cell. Big thanks in advance. |
All times are GMT +1. The time now is 11:10 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com