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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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