davidmnix
12-29-2016, 01:13 PM
I am trying to select a range of cells, count the number of cells with data in that range, and then use that value to define a for loop. I am receving an error on the "k =" line.
I know this is probabaly an elementary issue, but I am new to VBA. Thank you for any help you can offer
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "FLlist"
ActiveSheet.Range("FLlist").RemoveDuplicates Columns:=1, Header:= xlYes
Dim k As Integer
k = Value.CountA(Range("FLlist"))
For j = 1 To k
Sheets("YTD Work Orders").Range("$A$11:$AK$1260").AutoFilter Field:=6, _
Criteria1:=Sheets("Summary by FL").Cells(1 + j, 1).Value
Cost_YTD = Sheets("YTD Work Orders").Range("C6")
Sheets("Summary by FL").Cells(1 + j, 2) = Cost_YTD
Next j
I know this is probabaly an elementary issue, but I am new to VBA. Thank you for any help you can offer
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "FLlist"
ActiveSheet.Range("FLlist").RemoveDuplicates Columns:=1, Header:= xlYes
Dim k As Integer
k = Value.CountA(Range("FLlist"))
For j = 1 To k
Sheets("YTD Work Orders").Range("$A$11:$AK$1260").AutoFilter Field:=6, _
Criteria1:=Sheets("Summary by FL").Cells(1 + j, 1).Value
Cost_YTD = Sheets("YTD Work Orders").Range("C6")
Sheets("Summary by FL").Cells(1 + j, 2) = Cost_YTD
Next j