Вот почему динамически созданные элементы не реагируют на клики & nbsp;:
var body = $("body");
var btns = $("button");
var btnB = $("<button>B</button>");
// `<button>B</button>` is not yet in the document.
// Thus, `$("button")` gives `[<button>A</button>]`.
// Only `<button>A</button>` gets a click listener.
btns.on("click", function () {
console.log(this);
});
// Too late for `<button>B</button>`...
body.append(btnB);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>A</button>
В качестве обходного пути вы должны прослушивать все клики и проверять исходный элемент & nbsp;:
var body = $("body");
var btnB = $("<button>B</button>");
var btnC = $("<button>C</button>");
// Listen to all clicks and
// check if the source element
// is a `<button></button>`.
body.on("click", function (ev) {
if ($(ev.target).is("button")) {
console.log(ev.target);
}
});
// Now you can add any number
// of `<button></button>`.
body.append(btnB);
body.append(btnC);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>A</button>
Это называется «Event Delegation». Хорошие новости, это встроенная функция в jQuery: -)
var i = 11;
var body = $("body");
body.on("click", "button", function () {
var letter = (i++).toString(36).toUpperCase();
body.append($("<button>" + letter + "</button>"));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>A</button>
Попробуйте что-то вроде этого:
Dim sht As Worksheet, rng As Range, rngVis As Range
Set sht = ActiveSheet
Set rng = sht.Range("a1").CurrentRegion '<< the range with data and headers
If Application.CountA(rng) = 0 Then Exit Sub '<< exit if have no data...
rng.AutoFilter
rng.AutoFilter field:=2, Criteria1:="=*"
rng.AutoFilter field:=8, Criteria1:="=*In*"
'Next line should not throw an error even if all data
' rows are filtered, since there's always the header row visible
Set rngVis = rng.Columns("I").SpecialCells(xlCellTypeVisible)
If rngVis.Count > 1 Then '<< ignore if only the header row...
rngVis.SpecialCells(xlCellTypeBlanks).Value = "InsertValueHere"
End If