Copy range excel from Cell name dynamic by vba

ngocanh87

Board Regular
Joined
Mar 16, 2016
Messages
85
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hello all,

Can I copy range excel from Cell name dynamic to another sheet ?.
Allway Col A, name cell "Item No."

SSC-2023-145 AWAJI.xlsx
ABCDEFGHIJKLMNO
22ITEM No.PO NODISCRIPTION OF GOODS (MM)KG/M QUANTITY (PC) Net Weight (MT)U.PRICE (USD/MT)AMOUNT (USD)
271300522-3ΦOD101.6MM x WT4.8MM x MM/PC6,050 MM 11.561042.441132056,022.12
28300522-3ΦOD101.6MM x WT4.8MM x MM/PC6,050 MM 11.530.2091320275.88
29300522-3ΦOD101.6MM x WT4.8MM x MM/PC6,050 MM 11.51006.95813209,184.56
30300522-3ΦOD101.6MM x WT4.8MM x MM/PC6,050 MM 11.550.3481320459.36
312300522-3ΦOD114.3MM x WT5.3MM x MM/PC6,450 MM 14.2706.41113208,462.52
32300522-3ΦOD114.3MM x WT5.3MM x MM/PC6,450 MM 14.280.7331320967.56
33300522-3ΦOD114.3MM x WT5.3MM x MM/PC6,450 MM 14.217015.570132020,552.40
34300522-3ΦOD114.3MM x WT5.3MM x MM/PC6,450 MM 14.210.0921320121.44
35300522-3ΦOD114.3MM x WT5.3MM x MM/PC6,450 MM 14.230027.477132036,269.64
36300522-3ΦOD114.3MM x WT5.3MM x MM/PC6,450 MM 14.250.4581320604.56
37300522-3ΦOD114.3MM x WT5.3MM x MM/PC6,450 MM 14.220018.318132024,179.76
38300522-3ΦOD114.3MM x WT5.3MM x MM/PC6,450 MM 14.270.6411320846.12
INV
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Not clear for me.
Do you mean, click a button then an input box appear to ask which "Item No", for example, if user input "2", then copy range A31:O38 to new sheet?
 
Upvote 0
This table in sheet have a lot of data, I just want copy table from the Cell name: "Item No." (row dynamic) to last row of table by vba.
 
Upvote 0
I see the code for lastrow "TOTAL" to A9
How can I change copy from firstrow "ITEM No." to lastrow
1680681276512.png

Public Sub Copy_Data()

Dim lastCell As Range, wrkSht As Worksheet
Dim lastRow As Integer, firstCol As Range
Dim copyRng As Range

Set wrkSht = ActiveWorkbook.Worksheets("INV")
lastRow = Application.WorksheetFunction.Match("TOTAL", wrkSht.Range("A:A"))
Set firstCol = wrkSht.Range(wrkSht.Range("A9"), wrkSht.Cells(lastRow, 1))
Set copyRng = wrkSht.Range(firstCol, firstCol.End(xlToRight))

copyRng.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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