Excel Sheet Macros

MS Excel User defined Macros:



Before creating a user defined macro u will set the security level as either low or medium.

To set the security as low:

Tools->macros->security -> select the option as low as given below.

Creating a new macro for excel sheet:

Tools-->Macro-->Macros-->MacroName(give macroname)---> Create (click on create button)

Once click on create button new macro is created.

Tools-->Macro-->Macros-->Visual Basic Editor (click on this)

click on the visual basic Editor visual basic code window will be open with macro-name procedure.
so write the code for that macro in the code window and click on save button.

For example:


Sub border() //here border is macro name
Dim row, irow, row1 As Integer
row = 2
For row1 = row To ActiveSheet.UsedRange.Rows.Count [ no.of rows filled with data in current excel sheet]
If Not Range("B" & row1).Value = "" Then [to give the row top as thick line]

With Range("A" & row1 & ":" & "AT" & row1).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium [to give the row top as thick line]
.ColorIndex = xlAutomatic
End With
Else
End If
Next row1

Sub Auto_Open()
Call border
End Sub


Reference: http://www.techonthenet.com/excel/index.php


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: