I need a macro that when I place the cursor in cell A3 will copy cells A3...F3 to A4...F4. And then if I move the cursor to A6 will copy the cells A6…F6 to A7…F7.
Book1.xls
Any help would be appreciated.
Thank you,
akey
I need a macro that when I place the cursor in cell A3 will copy cells A3...F3 to A4...F4. And then if I move the cursor to A6 will copy the cells A6…F6 to A7…F7.
Book1.xls
Any help would be appreciated.
Thank you,
akey
try something like this
![]()
Please Login or Register to view this content.
Regards
tom1977
If You are satisfied with my solution click the small star icon on the left to say thanks.
try using the bellow macro, it is based on a double click instead of a single click.
I'm also attaching a workbook to show it working.
this code will also modify your subtotal formula to include the newly entered row.
![]()
Please Login or Register to view this content.
If you liked my solution, please click on the Star -- to add to my reputation
If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.
if you want use this code in A3 then A6 then A9 and so on then use this
![]()
Please Login or Register to view this content.
I tried cutting and pasting your macro but I keep getting a compile error "Expected End Sub"
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+z
'
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim intRow, intLen As Integer
If Target.Column = 1 Then
intRow = Target.Row
Range("A" & intRow + 1).Select
Selection.EntireRow.Insert
Range("A" & intRow & ":F" & intRow).Select
Selection.Copy
Range("A" & intRow + 1).Select
ActiveSheet.Paste
Application.CutCopyMode = False
intLen = Len(intRow)
If Right(Range("G" & intRow + 2).Formula, 3 + intLen) = ":G" & intRow & ")" Then
Range("G" & intRow + 2).Formula = Left(Range("G" & intRow + 2).Formula, Len(Range("G" & intRow + 2).Formula) - 1 - intLen) & intRow + 1 & ")"
End If
End If
End Sub
Any thoughts?
Thank you,
akey
instead of entering the macro into a new module under a sub, you need to enter it into the code view of the sheet (just double click on the sheet name in the VB editor) and paste it there
Great thanks it is working. The only problem is I don't want a new line inserted I just want those cells copied down so that they are on the same row as the subtotaled amount. I need the row content in yellow on the attached sheet.
Book2.xls
Thanks for all you help,
akey
in that case you could use this code instead, still based on a double click.
![]()
Please Login or Register to view this content.
Thanks DGagnon, it worked perfectly.
akey
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks