Excel VBA: move matching rows to another sheet

This VBA moves my paid jobs in my job list sheet (sheet1) to the sheet named “history” (sheet4).

If the value of sixth column (Column F) of a row in sheet1 is “closed”, that row is then moved to the end of sheet4.

Sub Button_Remove_Closed_Click()
With Sheet1
'    For Each rw In .UsedRange.Rows
'
'        If rw.Cells(6).Value = "Closed" Then
'            Target = Sheet4.UsedRange.Rows.Count + 1
'            rw.Copy Destination:=Sheet4.Rows(Target)
'            rw.Delete
'        End If
'    Next
'
'the above doens't work well as when for example row 5 is deleted, the old row 6 becomes row 5.
'this works :-)
Dim i, j
 
j = .UsedRange.Rows.Count
 
For i = 1 To j
    If .Cells(i, 6).Value = "Closed" Then
        Target = Sheet4.UsedRange.Rows.Count + 1
        .Rows(i).Copy Destination:=Sheet4.Rows(Target)
        .Rows(i).Delete
        i = i - 1
    End If
Next
 
End With
End Sub
Share

Word VBA: randomize paragraphs

Sub ran_para()
    n = ActiveDocument.Paragraphs.Count
    ReDim a(1 To 2, 1 To n)
    Randomize
    For i = 1 To n
        a(1, i) = Rnd
        a(2, i) = i
    Next
    For i = 1 To n - 1
        For j = i + 1 To n
            If a(1, j) > a(1, i) Then
                t = a(2, i)
                a(2, i) = a(2, j)
                a(2, j) = t
            End If
        Next
    Next
    'Documents.Add
    For i = 1 To n
        Set p = ActiveDocument.Paragraphs.Add
        p.Range.Text = ActiveDocument.Paragraphs(a(2, i)).Range.Text
    Next
End Sub
Share

SSL certificate chain order

Contrary to what you may find on the Internet, the trust chain of ssl certificate is actually from BIG to small.
It may not be matter to some browsers but matters to others. I installed the chain in reverse order but chrome and IE don’t complain. Firefox is more picky.

The merge command line goes like

COMODORSADomainValidationSecureServerCA (intermediate) > COMODORSAAddTrustCA (intermediate) > AddTrustExternalCARoot (root)

Resulting something like

<root>
...
<signer for your cert signer>
<your cert signer>
Share

jquery post

Use html5 to validate email before submit.

 
<html>
 
<head>
 
<script>
function save()
{        
 
        jQuery('#b2').attr("disabled", true);
        jQuery('#msg').html("Working. Please wait....");
 
        var query = jQuery('#forget').serialize();
        var url = '/bw_forget_password_jquery.php';
        jQuery.post(url, query, function (response) {
            jQuery('#msg').html(response);
            jQuery('#b2').removeAttr("disabled");
        });
        return false;
 
 
}
</script>
</head>
<body>
<form method="POST" id='forget' onsubmit="return save();" action="#">
<br>Forget your username/password? Simply type your email address below and click Submit and you will receive them in an email.<br>
<input type="email" name="email" size="25">
<input type="submit" value="Submit" id="b2">
<div id = 'msg'></div>
</form>
</body>
</html>
Share

php mysqli store_result

When using prepare to prepare a statement to retrieve LOBs the method order matters.
Also, method ‘store_result()’ must be called and be called in correct order.
Failure to observe this causes PHP/MySQLi to crash or return an erroneous value.
The proper procedure order is: prepare -> execute -> store_result -> bind -> fetch

Share