Hello,
im trying to put a vba code together that selects the entirerows with a specific value by doubleclick of a cell.
I have the code working with a fixed range but not by doublecilck.
Sombody see what is wrong here?
Code that works:
Code doesnt work:
im trying to put a vba code together that selects the entirerows with a specific value by doubleclick of a cell.
I have the code working with a fixed range but not by doublecilck.
Sombody see what is wrong here?
Code that works:
VBA Code:
Sub Counter()
Dim Valuehiderow As Long
Dim y, rng, rng2 As Range
Set rng = Range(Range("N54"), Range("N54").End(xlDown))
With rng
For Each y In .Rows
If Application.CountIf(y, "INPUT") > 0 Then
Valuehiderow = Valuehiderow + 1
End If
Next
End With
Set rng2 = Range(Range("N54"), Range("N54").Offset(Valuehiderow))
rng2.Select
End Sub
Code doesnt work:
VBA Code:
Sub Counter2()
Dim Valuehiderow As Long
Dim y, rng, rng2 As Range
Set rng = Range(Target.Offset(12), Target.End(xlDown))
With rng
For Each y In .Rows
If Application.CountIf(y, "INPUT") > 0 Then
Valuehiderow = Valuehiderow + 1
End If
Next
End With
Set rng2 = Range(Target.Offset(1), Target.Offset(Valuehiderow))
rng2.EntireRow.Select
MsgBox (Valuehiderow)
End Sub