Header Ads Widget

Microsoft Excel VBA

 Microsoft Excel VBA:

Microsoft VBA

What is Microsoft Excel VBA

Microsoft VBA stands for Visual Basic for Applications is the programming language of Excel and other Office programs. VBA is powerful and productive with regards to tedious answers for designing or remedy issues. For instance, have you ever changed the style of the section at the head of each page in Word? Have you ever needed to reformat various tables that were stuck from Excel into a Word record or an Outlook email? Have you ever needed to roll out a similar improvement in numerous Outlook contacts. VBA programs can be attached to a menu button, a macro, a keyboard shortcut. 



Where to find this Program:

Microsoft VBA


The organization run by the most extravagant man on the planet. Dominate, alongside different individuals from Microsoft Office 2003, incorporates the VBA language (at no additional charge). More or less, VBA is the device that individuals use to create programs that control Excel.

Enabling the Developer Tab:


To utilize VBA, you need the "Designer" tab empowered. The "Engineer" tab has a few fastens and highlights that upgrade the manner in which you make spreadsheets. In the event that you don't have the "Designer" tab empowered, follow these subsequent stages to empower it. 

Snap the "Record" strip tab, and afterward click the "Choices" connect that shows in the base left segment of the Excel window. This opens another design window where you can set inclination for various components of Excel. Snap the "Tweak Ribbon" choice in the left board.

Creating a Button on Your Spreadsheet


At the point when you click the "Addition" button, a dropdown shows the entirety of the accessible parts that you can add to your spreadsheets. The upper left control in the "Structure Controls" area has the catch control. You can float your mouse over every one of the parts in the rundown to perceive what you can add to a spreadsheet. On the off chance that you know about HTML page segments, at that point you will perceive a large portion of the accessible segments in the dropdown. 

Snap the catch control and afterward you can draw the catch on your spreadsheet. Drawing a catch lets you make it as extensive as little as you need. After you draw the catch, a window opens where you can allot a full scale.

Working in the VBA Workspace:

With the VBA supervisor open, you presently have a capacity prepared to alter for your catch. Anything you type in the "Sub" and "End Sub" articulations will run when you click the Button1 part. At the point when you begin working with VBA, you need to make simple capacity articulations so you can follow what is happening as the code runs. In this model, we will add some content to a cell inside the current spreadsheet.
 
Inside the sub start and end phrases, type the accompanying code:


The VBA workspace looks a similar whether you program macros in Word or Excel. It's where you can program the full scale and view all other code that you've recently made.

Writing Some Simple VBA Code:

Sub Demo()

 

 

Dim rng As Range

Dim PowerPointApp As Object

Dim myPresentation As Object

Dim mySlide As Object

Dim myShape As Object

 

'Copy Range from Excel

  Set rng = ThisWorkbook.ActiveSheet.Range("A1:C12")

 

'Create an Instance of PowerPoint

  On Error Resume Next

   

    'Is PowerPoint already opened?

      Set PowerPointApp = GetObject(class:="PowerPoint.Application")

   

    'Clear the error between errors

      Err.Clear

 

    'If PowerPoint is not already open then open PowerPoint

      If PowerPointApp Is Nothing Then Set PowerPointApp = CreateObject(class:="PowerPoint.Application")

   

    'Handle if the PowerPoint Application is not found

      If Err.Number = 429 Then

        MsgBox "PowerPoint could not be found, aborting."

        Exit Sub

      End If

 

  On Error GoTo 0

 

'Optimize Code

  Application.ScreenUpdating = False

 

'Create a New Presentation

  Set myPresentation = PowerPointApp.Presentations.Add

 

'Add a slide to the Presentation

  Set mySlide = myPresentation.Slides.Add(1, 11) '11 = ppLayoutTitleOnly

 

'Copy Excel Range

  rng.Copy

 

'Paste to PowerPoint and position

  mySlide.Shapes.PasteSpecial DataType:=2  '2 = ppPasteEnhancedMetafile

  Set myShape = mySlide.Shapes(mySlide.Shapes.Count)

 

    'Set .Left = 66

      myShape.Top = 152

 

'Make PowerPoint Visible and Active

  PowerPointApp.Visible = True

  PowerPointApp.Activate

 

'Clear The Clipboard

  Application.CutCopyMode = False

 

End Sub



Happy Learning with Microsoft Excel VBA. 

Post a Comment

0 Comments