VBA Coding for Copy & Paste Rows of Data Based on Company Name which is selected from Drop Down in Cell A1 HELP PLEASE

Galapagos15

Board Regular
Joined
Sep 16, 2015
Messages
100
I wrote VBA to copy and paste rows of data that match a specific company name from another file which uses a filter to select the needed data. This works but I need the criteria coding to be changed so I don't have to manually list the company name (i.e. ABC Company) but instead will be the Company Name which the user selected from a drop down box in cell A1 in my working file.

I know this line needs recoded but don't know how ActiveSheet.Range("$a$2:$bd$15446").AutoFilter Field:=2, Criteria1:= _"ABC Company"


Sub MacroFSPMedical()


Dim ReportWbk As Workbook 'workbook with report data

Dim Report As String 'name of file with report data

Set TempBook = ThisWorkbook

Application.FileDialog(msoFileDialogFilePicker).Show

Report = Application.FileDialog(msoFileDialogFilePicker).SelectedItems(1)

Set ReportWbk = Workbooks.Open(Report)
Sheets("Medical").Select
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$a$2:$bd$15446").AutoFilter Field:=2, Criteria1:= _
"ABC Company"
ActiveSheet.UsedRange.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
TempBook.Sheets("FSP Medical Data").Range("a3").PasteSpecial xlPasteValues


End Sub

Thanks in advance!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Watch MrExcel Video

Forum statistics

Threads
1,129,568
Messages
5,637,094
Members
416,957
Latest member
Brovashift

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
Top