«

Dec
28

Excel: VBA Examples-3

Get the max row cotain value of the sheet
Sub GetMaxRow()
n = Cells.Find(“*”, , , , 1, 2).Row
MsgBox n
End Sub
Get the max row of column A which is not empty
Sub GetMaxRowOfColumnA()
n = Range(“a65536″).End(xlUp).Row
Range(“B1″) = n
End Sub
Insert text frame in selected area
Sub InsertTextFrame()
For Each rag In Selection
n = n & rag.Value & Chr(10)
Next
ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, ActiveCell.Left + ActiveCell.Width, ActiveCell.Top + ActiveCell.Height, 250#, 100).Select
Selection.Characters.Text = “issues:” & n
With Selection.Characters(Start:=1, Length:=3).Font
.Name = “bold”
.FontStyle = “regula”
.Size = 12
End With
End Sub
Input multi address comment
Sub InsertComments()
On Error Resume Next
Dim r As Range
If Selection.Cells.Count > 0 Then
For Each r In Selection
r.Comment.Delete
r.AddComment
r.Comment.Visible = False
r.Comment.Text Text:=”cell” & r.Address & ” of ” & Selection.Address
Next
End If
End Sub
Input comments automatically
Sub InsertCom