Find, Cut and Paste Macro

Realrookie

New Member
Joined
Apr 25, 2022
Messages
9
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Hello all,

A little experience with VBA.
I did search the forum and found several similar posts but I cannot modify any opf them due to lacking knowledge.

I have a master sheet with over 30k lines of data. From here in Sheet1, Column B i have to find the customer reference, cut that row (or rows if multiple available) and paste it in the Sheet2 on the next empty cell in Column A.

I have seen several macro's on this forum that all use pre-defined search terms but none that has a find "Box".

Any help or pointers would be greatly apreciated.

Red
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
With over 30k rows, its better that using VBA autofilter, then copy visible rows at one, and paste to other sheet
Without image/screenshot sample, its hard to see how the data look like. Try.
 
Upvote 0
With over 30k rows, its better that using VBA autofilter, then copy visible rows at one, and paste to other sheet
Without image/screenshot sample, its hard to see how the data look like. Try.
I have added a screenshot of the sample file (which I could not upload here). I was thinking of autofilter but got stuck on the criteria, as this changes.
 

Attachments

  • Capture.JPG
    Capture.JPG
    238.2 KB · Views: 6
Upvote 0
Sample.xlsx
ABCDEFGH
1CreationDateCustomer referenceISBNBook TypeTitleQtyPublisherUnit Price
37 04/04/202270000672839780367501655SoftGlasgow (High-Rise Homes, Estates and Communities in the Post-War Period)1
38 04/04/202270000672849780367864965SoftIntroduction to BioMEMS1
39 04/04/202270000672849781138579415SoftASR Sketching as Design Thinking1
40 04/04/202270000672849780415787307SoftDigital Media Foundations (An Introduction for Artists and Designers)1
41 04/04/202270000672859781138083875SoftArchipelago Tourism (Policies and Practices)1
42 04/04/202270000672859780415748537Soft(Infrastructural Lives)1
43 04/04/202270000672859781138924512SoftAn Introduction to Economic Geography (Globalisation, Uneven Development and Place)1
44 04/04/202270000672869781611322996Soft(Paleoethnobotany, Third Edition (A Handbook of Procedures))1
45 04/04/202270000672879781138490468SoftIdeological Equals (Women Architects in Socialist Europe 1945-1989)1
46 04/04/202270000672889780367133177SoftEar, Nose and Throat Diseases of the Dog and Cat1
47 04/04/202270000672889781498754415SQBEssentials of Clinical Anatomy of the Equine Locomotor System1
49 04/04/202270000672909780367449834SoftFlexural-Torsional Buckling of Structures1
50 04/04/202270000672909789054101864SQBSupport of Underground Excavations in Hard Rock1
51 04/04/202270000672909780419160304SoftUnderground Excavations in Rock1
52 04/04/202270000672919780415567671SoftReligious Studies1
53 04/04/202270000672929780415672573SoftReading Images (The Grammar of Visual Design)4
54 04/04/202270000672929781138048744SoftAcademic Writing (A Handbook for International Students)4
256
Sheet1
 
Upvote 0
which customer criteria to filter?
and criteria come from a cell, or from input box?
 
Upvote 0
which customer criteria to filter?
and criteria come from a cell, or from input box?
If it can be done from an input box, that would be great, as currently, I am using Find (to find the customer reference) then cutting the entire row (or rows) and paste in Sheet2.
 
Upvote 0
VBA Code:
Option Explicit
Sub CopyPaste()
Dim lr&
Worksheets("Sheet1").Activate
lr = Cells(Rows.Count, "B").End(xlUp).Row
ActiveSheet.AutoFilterMode = False
Range("A1:H" & lr).AutoFilter field:=2, Criteria1:=InputBox("Customer reference: ")
Range("A1:H" & lr).SpecialCells(xlCellTypeVisible).Copy
Sheets.Add after:=Worksheets("Sheet1")
ActiveSheet.Cells(1, 1).PasteSpecial (xlPasteValues)
Worksheets("Sheet1").AutoFilterMode = False
Application.CutCopyMode = False
End Sub
 
Upvote 0
Sheets.Add after:=Worksheets("Sheet1")
You are a godsend. But as Sheet2 is already active (at all times as that becomes the manifest), I want add the copied data into the next empty Row with
VBA Code:
Worksheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste
But then I get a 400 error. Headers on Sheet 2 are always active as well.
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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