Excel VBA For Each Worksheet Loop

Try to slightly modify your code: Sub forEachWs() Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets Call resizingColumns(ws) Next End Sub Sub resizingColumns(ws As Worksheet) With ws .Range(“A:A”).ColumnWidth = 20.14 .Range(“B:B”).ColumnWidth = 9.71 .Range(“C:C”).ColumnWidth = 35.86 .Range(“D:D”).ColumnWidth = 30.57 .Range(“E:E”).ColumnWidth = 23.57 .Range(“F:F”).ColumnWidth = 21.43 .Range(“G:G”).ColumnWidth = 18.43 .Range(“H:H”).ColumnWidth = 23.86 .Range(“i:I”).ColumnWidth = 27.43 … Read more

jQuery: How to use each starting at an index other than 0

Use slice() http://api.jquery.com/slice/ $(‘#someElemID’).find(‘.someClass’).slice(nextIndex).each( … btw if the elements are static, consider caching: var $elms = $(‘.someClass’, ‘#someElemID’), nextIndex = 0; for (var j = 1; j <= someCount; j++) { // do outside loop stuff $elms.slice(nextIndex).each(function(index) { if (/*this is right one*/) { nextIndex = index + 1; return false; } }); } That … Read more

jQuery animated number counter from zero to value

Your thisdoesn’t refer to the element in the step callback, instead you want to keep a reference to it at the beginning of your function (wrapped in $thisin my example): $(‘.Count’).each(function () { var $this = $(this); jQuery({ Counter: 0 }).animate({ Counter: $this.text() }, { duration: 1000, easing: ‘swing’, step: function () { $this.text(Math.ceil(this.Counter)); } … Read more

Return a value when using jQuery.each()?

You are jumping out, but from the inner loop, I would instead use a selector for your specific “no value” check, like this: function validate(){ if($(‘input[type=text][value=””]’).length) return false; } Or, set the result as you go inside the loop, and return that result from the outer loop: function validate() { var valid = true; $(‘input[type=text]’).each(function(){ … Read more

jQuery when each is completed, trigger function

You can use $.when()/$.then() to redirect your users after all the AJAX requests are done: //create array to hold deferred objects var XHRs = []; $(‘#tabCurrentFriends > .dragFriend’).each(function(){ var friendId = $(this).data(‘rowid’); //push a deferred object onto the `XHRs` array XHRs.push($.ajax({ type: “POST”, url: “../../page/newtab.php”, data: “action=new&tabname=” + tabname + “&bid=” + brugerid + “&fid=” … Read more