Filter based on Input box and copy and paste data

eviehc123

New Member
Joined
Jan 21, 2019
Messages
32
Hi all,

Please can someone help me with the below code. As you can see I am filtering based on what is placed in the input box. The cell "I19" is blank so I want the filter to bring up any row of data in which the cell is blank in the relevant column.

I then want to copy select data out of what is filtered and paste it into a new sheet called "Outstanding Clearances".

For example, I want to copy the data in columns "A", "C", "D" and "H" then paste this data in cells "A:D" in sheet "Outstanding Clearances".

I want it to copy every row that appears in the filter. I hope this makes sense. Please see below what I have so far:

Code:
Sub Button6_Click()
'
' Macro7 Macro
'


'
    Dim myValue As Variant
    myValue = InputBox("Enter the pre-employment clearance. E.g. References, Medical, DBS, RTW, Onboarding.", "Search outstanding pre-employment clearances")
    Range("N17").Value = myValue
    Range("N17").Select
    If Range("N17") = "References" Then
    With Sheets("HR Advice & Admin")
      FilterString = Sheets("Menu").Range("I29").Value
      .Range("$AC$1:$AcS$286").AutoFilter Field:=1, Criteria1:=FilterString
     Intersect(.AutoFilter.Range.Offset(1), .Range("A:A")).Copy
     Sheets("Outstanding clearances").Range("A2:A" & Rows.Count).SpecialCells(xlVisible)(1).PasteSpecial xlPasteValues
     End With
      End If
End Sub

Thanks,
Eve
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Watch MrExcel Video

Forum statistics

Threads
1,129,343
Messages
5,635,742
Members
416,876
Latest member
Sokali

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