Hello Everyone,
i'm new to vba and I want to make a filter depending on some criteria and then copy the visible cells into an array.
I made the code below but it takes even the hidden cells values.
Can anyone please help me?
Sub BOM_extract()
Dim i As Long
Dim lastline As Long
Dim code_obj As String
Set Datasheet = Sheets("Data")
Set TSheet = Sheets("Raw_data")
Datasheet.Select
Selection.AutoFilter
Datasheet.Select
Datasheet.Range("$A$2:$EI$254").AutoFilter Field:=11, Criteria1:="Table"
lastline = Datasheet.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1
Dim my_code_obj() As String
ReDim my_code_obj(1 To lastline)
For i = 1 To lastline
my_code_obj(i) = Range("A3").Offset(1).SpecialCells(xlCellTypeVisible).Cells(i, 1).Value
Next i
TSheet.Select
Range("B3:B" & lastline).Value = Excel.WorksheetFunction.Transpose(my_code_obj)
End Sub
it would be appreciated
i'm new to vba and I want to make a filter depending on some criteria and then copy the visible cells into an array.
I made the code below but it takes even the hidden cells values.
Can anyone please help me?
Sub BOM_extract()
Dim i As Long
Dim lastline As Long
Dim code_obj As String
Set Datasheet = Sheets("Data")
Set TSheet = Sheets("Raw_data")
Datasheet.Select
Selection.AutoFilter
Datasheet.Select
Datasheet.Range("$A$2:$EI$254").AutoFilter Field:=11, Criteria1:="Table"
lastline = Datasheet.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1
Dim my_code_obj() As String
ReDim my_code_obj(1 To lastline)
For i = 1 To lastline
my_code_obj(i) = Range("A3").Offset(1).SpecialCells(xlCellTypeVisible).Cells(i, 1).Value
Next i
TSheet.Select
Range("B3:B" & lastline).Value = Excel.WorksheetFunction.Transpose(my_code_obj)
End Sub
it would be appreciated