Copy values from a range in one sheet and paste them into empty rows of a table in another sheet

sopphiron

New Member
Joined
Jan 14, 2024
Messages
3
Office Version
  1. 2021
I have a list of goods as can be seen below, I want to use a button (transfer data) to click on and the rows be copied into a table in another sheet in a way to fill the empty rows from the top of the table

Book1.xlsm
ABCDEFGH
1
2
3GoodsPriceCountTotal Price
4Good11005500
5Good2503150
6Good3456270
7Good41090900
8
9
AAA
Cell Formulas
RangeFormula
E4:E6E4=D4*C4



the table the data to be copied in:

Book1.xlsm
ABCDEFG
1
2NoGoodsPriceCountTotal Price
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
BBB
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi sopphiron,

The code below will copy what is on tab AAA from cell B4 onwards and paste it to tab BBB at the bottom of any data already there. Will not do anything if there is nothing in cell B4 and works for any number of entries from 1 upwards.

VBA Code:
Sub MoveData()

Dim Lrow As Integer

On Error GoTo 911

Lrow = Range("B3").End(xlDown).Row

    Range(Range("B4"), Range("B" & Lrow).End(xlToRight)).Copy
    
    Sheets("BBB").Select
    Range("C26").End(xlUp).Offset(1, 0).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

911

End Sub

I've run it twice in my example below...
1717493745705.png


To make this run with a button add in any shape you like, right click >assign macro and select 'MoveData'. Done!
1717494083308.png
1717494126871.png
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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