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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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