Showing posts with label MACROS VBA BASICS. Show all posts
Showing posts with label MACROS VBA BASICS. Show all posts

Tuesday, 29 September 2015

Excel VBA Macro To Change Border Line Styles

Excel VBA Macro To Change Border Styles


Sub Borders()

        Sheets.Add
        'Borders
        Range("B5:e15").Borders.LineStyle = xlContinuous
        Range("B5:e15").Borders.LineStyle = xlDot
        Range("B5:e15").Borders.LineStyle = xlThick
        Range("B5:e15").Borders.LineStyle = xlSingle
        Range("B5:e15").Borders.LineStyle = xlDouble
        Range("B5:e15").Borders.LineStyle = xlNone
       
End Sub

Friday, 25 September 2015

EXCEL Macro(VBA) Code to Sort the Data

EXCEL Macro(VBA) Code to Sort the Data Based on One Particular Column

First Enter the large data in Excel sheet then Execute this Macro

Sub Sorting()
Dim X As Integer

X = InputBox("Enter The SortBase Column:")
Columns(X).Select

ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Cells(1, X), _
  SortOn:=xlSortOnValues,
  Order:=xlAscending,
  DataOption:=xlSortNormal

With ActiveWorkbook.ActiveSheet.Sort
  .SetRange Range("A1:H300")
  .Header = xlYes
  .MatchCase = False
  .Orientation = xlTopToBottom
  .SortMethod = xlPinYin
  .Apply
 End With
End Sub

Sunday, 7 June 2015

Macro Code for Displaying the Names of Worksheets One by One.


Using Macro Code Displaying the Names of Worksheets in a Workbook.

After executing this code it displaying all worksheets names one by one.

MACRO CODE:

Sub for_each()                  
Dim sh As Worksheet
For Each sh In Worksheets      'For Each Loop
MsgBox sh.Name                    'Msgbox diplaying the Names
Next sh
End Sub


F5 - Execute the Program