Tuesday, August 20, 2013

Excel VBA for beginners

Excel VBA for beginners

Get WorkSheet and get cells inside Excel with VBA


Build macro in Excel with VBA easily by knowing at first the basic principal of object order inside Excel.

Excel file -> Excel Sheet -> Excel Cell.

When you are working in VBA inside Excel, you don’t need to worry about the Excel file because the Excel file is the file you opened.

That means that you just need to get the right Excel Sheet first. Here is a simple Youtube video and it will illustrate the very basic steps.



To get the Excel Worksheet Name:


Public Sub test1()

    'Declare your objects so your could
    'easily retrieve the functions
    'from it
    Dim ws As Worksheet
   
    
    'Assign the ActiveSheet to your "empty" ws variable
    ws = Application.ActiveSheet
   
    'Display the sheet Name for testing
    MsgBox ws.Name

End Sub


To get the Cells Name inside a worksheet:





Public Sub test1()

    'Declare your objects so your could
    'easily retrieve the functions
    'from it
    Dim ws As Worksheet
    Dim index_row As Integer
    Dim index_col As Integer

   
    'Assign the ActiveSheet to your "empty" ws variable
    ws = Application.ActiveSheet
   
    'Circle to a few row and lines
    For index_row = 1 To 10
        For index_col = 1 To 2
            MsgBox ws.Cells(index_row, index_col)
        Next
    Next
       
End Sub

There are thousands of tutorial on the internet. You could build any functions in VBA inside Excel by your own. If you wish to make something more professional and powerful, you could always ask for a professional to do your VBA Excel programming for you. I a good idea to shop around because there is an incredible wide price range for this.

Visit my web site http://checktechno.ca to have an idea of the type of programming I work with. I usually offer software development in engineering applications.



No comments:

Post a Comment