VBA Select First Row of Data After Autofilter

srj1359

New Member
Joined
Mar 5, 2015
Messages
46
Office Version
  1. 2016
Platform
  1. Windows
Hello!

I am struggling with a problem I'm hoping can please help me solve. My data headers are on row 8. I need to filter column X to show dates before or equal to today and then select the first row of data and then all rows until the end.

I trimmed some out, but here is all I think you'll need to see of what I have so far.

VBA Code:
'Filter all date cells before or equal to today
    Sheets("Quote Summary").Select
    If Not Worksheets("Quote Summary").Range("A8").AutoFilter Then
    Worksheets("Quote Summary").Range("A8").AutoFilter
    End If
    ActiveSheet.Range("X8").AutoFilter Field:=24, Criteria1:= _
    "<=" & Now(), Operator:=xlAnd

'Copy from Quote Summary tab to Advantage Agreement Upload tab
  Dim lr As Long, lr2 As Long, sh2 As Worksheet
  Set WB1 = ActiveWorkbook
  Set sh2 = Sheets("Advantage Agreement Upload")
  With Sheets("Quote Summary")
    lr = .Range("B" & Rows.count).End(3).Row
    lr2 = sh2.Range("H" & Rows.count).End(3).Row + 1
   
    sh2.Range("F" & lr2).Resize(lr - 8, 1).Formula = "=Opportunity!$P$2"
    sh2.Range("F" & lr2).Resize(lr - 8, 1).Copy
    sh2.Range("F" & lr2).Resize(lr - 8, 1).PasteSpecial Paste:=xlPasteValues
   
    sh2.Range("H" & lr2).Resize(lr - 8, 1).Value = .Range("A9:A" & lr).Value
   
    sh2.Range("L" & lr2).Resize(lr - 8, 1).Formula = "=IF(H25="""","""",VLOOKUP(K25,'Upload Data'!V:X,3,FALSE))"
    sh2.Range("L" & lr2).Resize(lr - 8, 1).Copy
    sh2.Range("L" & lr2).Resize(lr - 8, 1).PasteSpecial Paste:=xlPasteValues

I would really appreciate any assistance.

Thanks so much!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,091
Office Version
  1. 2016
Platform
  1. Windows
Are your dates sorted in column X?
If not then you had to copy only the visible cells.
The IF formula can you beter copy from row 2: "=IF(H2="""","""",VLOOKUP(K2,'Upload Data'!V:X,3,FALSE))"
 

Watch MrExcel Video

Forum statistics

Threads
1,130,361
Messages
5,641,653
Members
417,229
Latest member
BODYCOTE

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