AutoFilter, Add formula then fill down to last row

decadence

Well-known Member
Joined
Oct 9, 2015
Messages
524
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]"
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

BarryL

Well-known Member
Joined
Jan 20, 2014
Messages
1,421
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
 

decadence

Well-known Member
Joined
Oct 9, 2015
Messages
524
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2010
  5. 2007
Platform
  1. Windows
Works Perfectly, Thank you BarryL I haven't entered the Ubound stage of learning yet. Much appreciated for the code.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,514
Messages
5,602,086
Members
414,501
Latest member
mdhaumyu

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