AutoFilter, Add formula then fill down to last row

decadence

Well-known Member
Joined
Oct 9, 2015
Messages
525
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2010
  5. 2007
Platform
  1. Windows
Hi, I want to be able to filter on column B then add the value from Column H and put it into Column C, then fill down to the last row of filtered data, However I am struggling to find an answer on how to add the cell from column H while filtered, can someone help with this please.

Here is what I have so far

Code:
    Columns("B:B").AutoFilter Field:=1, Criteria1:="DNF_"
    Lastrow = Range("A" & Rows.Count).End(xlUp).Row
    Range(Range("C2"), Range("C" & Lastrow)).FormulaR1C1 = "=RC[5]"
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
maybe try the below?

Code:
Sub copyover()
  Dim a, b
  Dim i As Long
  a = Range("B1", Range("B" & Rows.Count).End(xlUp)).Value
  ReDim b(1 To UBound(a), 1 To 1)
  For i = 1 To UBound(a)
    If a(i, 1) = "DNF_" Then b(i, 1) = Range("H" & i).Value
  Next i
  Application.ScreenUpdating = False
  With Range("A1").Resize(UBound(a), 3)
    .Columns("C:C").Value = b
    On Error GoTo 0
  End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
Works Perfectly, Thank you BarryL I haven't entered the Ubound stage of learning yet. Much appreciated for the code.
 
Upvote 0

Forum statistics

Threads
1,214,810
Messages
6,121,690
Members
449,048
Latest member
81jamesacct

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