Below code is working as intended. However, I want to substitute the criteria "T10598" with a cell. I tried doing that with code no. 2. But I'm getting the "Type Mismatch" error. Can one of you point out what I'm doing wrong?
I'm quite new to VBA, so sorry for the stupid questions 
[VBA]Option Explicit
Sub test()
Dim x
Dim cell As Range
If Application.CountIf(Sheets("Personaledata").Columns(1), "T10598") = 0 Then Exit Sub
With Sheets("Personaledata")
With .Range("a1", .Cells.SpecialCells(11)).Resize(, 3)
x = Filter(.Parent.Evaluate("transpose(if(" & .Columns(1).Address & _
"=""T10598"",row(1:" & .Rows.Count & "),char(2)))"), Chr(2), 0)
x = Application.Index(.Value, Application.Transpose(x), [{2,3}])
End With
End With
Sheets("Personale").Range("A3:B22,A27:A46,A52:A71,A77:a96,A102:a121,A127:a146").ClearContents
Sheets("Personale").Range("a22").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a46").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a71").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a96").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a121").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a146").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
For Each cell In Sheets("Personale").Range("A3:A22,A27:A46,A52:A71,A77:a96,a102:a121,A127:a146")
If IsEmpty(cell) Then
cell.EntireRow.Hidden = True
End If
If Not IsEmpty(cell) Then
cell.EntireRow.Hidden = False
End If
Next
End Sub
[/VBA]
CODE NO 2
[VBA]Option Explicit
Sub test()
Dim x
Dim cell As Range, t
t = Sheets("Baggrundsdata").Range("B3")
If Application.CountIf(Sheets("Personaledata").Columns(1), t) = 0 Then Exit Sub
With Sheets("Personaledata")
With .Range("a1", .Cells.SpecialCells(11)).Resize(, 3)
x = Filter(.Parent.Evaluate("transpose(if(" & .Columns(1).Address & "=" & t & ",row(1:" & .Rows.Count & "),char(2)))"), Chr(2), 0)
x = Application.Index(.Value, Application.Transpose(x), [{2,3}])
End With
End With
Sheets("Personale").Range("A3:B22,A27:A46,A52:A71,A77:a96,A102:a121,A127:a146").ClearContents
Sheets("Personale").Range("a22").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a46").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a71").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a96").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a121").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
Sheets("Personale").Range("a146").End(xlUp)(2).Resize(UBound(x, 1), 1).Value = x
For Each cell In Sheets("Personale").Range("A3:A22,A27:A46,A52:A71,A77:a96,a102:a121,A127:a146")
If IsEmpty(cell) Then
cell.EntireRow.Hidden = True
End If
If Not IsEmpty(cell) Then
cell.EntireRow.Hidden = False
End If
Next
End Sub[/VBA]