HI Bernie
When I add this code to my macro, it fills the first cell, then gives me a
message to tell me what the first cell is, but it exits out and does not run
the rest of my macro and it doesn't fill all the other cells in the row
related to filter I've applied.
Below is the Macro as I have it so farThis works quite well, only the first
loop doesn't stop and it eventually comes back with an error (after it has
gone down the whole column!)
Sub BacklogFormula()
Sheets("Build PE Config").Select
Rows("1:1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="Ready"
Cells(Range("I1").CurrentRegion.Offset(1,
0).SpecialCells(xlCellTypeVisible).Row, 9).Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<=0.33,""Pipeline"",""Backlog"")"
Cells(Range("I1").CurrentRegion.Offset(1,
0).SpecialCells(xlCellTypeVisible).Row, 9).Select
Dim i As Long
With Selection
Do Until .Offset(i, 0).Value <= 0
i = i + 1
.Copy Destination:=.Offset(i, 0)
Loop
End With
Selection.AutoFilter Field:=3, Criteria1:="Completed"
Cells(Range("I1").CurrentRegion.Offset(1,
0).SpecialCells(xlCellTypeVisible).Row, 9).Select
ActiveCell.FormulaR1C1 = "=IF(R[-25]C[-1]<=0.33,""On time"",""Missed"")"
Cells(Range("I1").CurrentRegion.Offset(1,
0).SpecialCells(xlCellTypeVisible).Row, 9).Select
Selection.FillDown
Dim i As Long
With Selection
Do Until .Offset(i, 0).Value <= 0
i = i + 1
.Copy Destination:=.Offset(i, 0)
Loop
End With
End Sub
Thanks for your help so far, I'm learning all the time
Bernie Deitrick said:
Anita,
I made a copy and paste error, and left off the last line:
Next myCell
Sorry about that,
Bernie
MS Excel MVP
Hi Bernie
I gave this one a try, but I get an error VB wants me to use 'Next' if i
use
'With'
:
Anita,
Let's say that your table starts in cell A1 and is continguous. To
identify
the first blank cell in the the ninth column after filtering, simply use
something like:
Dim myCell As Range
For Each myCell In Range("A1").CurrentRegion. _
Columns(9).SpecialCells(xlCellTypeVisible)
If IsEmpty(myCell) Then
MsgBox "The first blank Cell is " & myCell.Address
Exit Sub
End If
HTH,
Bernie
MS Excel MVP
Hi
I have a list of tasks that I have extacted from a database. There are
8
columns of data. I've applied a filter to one of the columns and then
I
was
to put a formula in the ninth column but only in the cells included in
the
filter. I then want to filter the same column on different criteria,
and
add
a different formula to the relevant cells in the ninth column as
well.
I've
worked it all out, apart from how to ensure that it will always select
the
correct cell to put the formula in.
Any help would be much apprieciated.