copy cell and cell above onto different sheet, under the next available line.

Luke1690

Board Regular
Joined
Jul 26, 2022
Messages
121
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Good morning guys,

I'm working on a ordering system that will put selected orders on a new sheet, so it can be sent off to be ordered.

i have multiple parts in different ranges on a sheet , (sheet1). without me doing a separate code for each part , is there a way that when a cell is selected it always copies the cell above aswell.
and then pastes it on the next available line in sheet2

for example

sheet1
selecting A2 (Copies A2:A1) & Pastes it into Sheet2 range D3:D2)

Select B2 (Copies B2:B1 & Pastes it into sheet2 range D5:D4)

The cell above is always an image of the part.

Thanks for you help guys, im alright at reading code and finding out what each line does, so don't worry about using my ranges, i will make any changes.

any more information please let me know.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I suspect I might be missing something here but do you just mean something like this ?

VBA Code:
Sub TestCopy()

    Dim shtDest As Worksheet
    Dim cellActive As Range
    
    Set cellActive = ActiveCell
    Set shtDest = Worksheets("Sheet2")
    
    If cellActive.Row = 1 Then Exit Sub
    
    shtDest.Range("D" & Rows.Count).End(xlUp).Offset(1).Resize(2).Value = cellActive.Offset(-1).Resize(2).Value
    
End Sub
 
Upvote 0
Thanks for your response Alex, that is exactly what i was after.

if the top cell was an image inside the cell how could i get that to copy.

it currently just shows as Value after using your macro
 
Upvote 0
If none of the cells being copied have formulas then swap out the last line which is effectively a paste values to a straight copy:
VBA Code:
    cellActive.Offset(-1).Resize(2).Copy Destination:=shtDest.Range("D" & Rows.Count).End(xlUp).Offset(1)
 
Upvote 0
Solution

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top