X

VBA Language in Excel

The VBA (Visual Basic for Application) Excel is not different from that of the other instruments of the Office suite, what changes is the approach to development, because in this case you must know how to disentangle between the various cells as if we were playing a naval battle.
The main concept on which we think is the “sheet”, which is the worksheet. In Excel, we can have all the worksheets that we want to work on it we can referenced through an array that has the serial number as an index sheet or its name. For example, to write the value 10 to cell “C3” of the first sheet we have to write:

Worksheets (1). Cells (3, 3) = 10 or Worksheets (“Sheet1”). Cells (3, 3) = 10

Very simple, you quickly realize how easy it is to make calculations on the entire sheet of paper or taking the values in two different sheets. The use of Excel I can see very well for documents such as invoices, I see it much more difficult for the warehouse to which I much prefer Access. As an example to understand the working side programming with VBA in Excel, see how you can take two values in two fixed cells on the same sheet, do the multiplication and write the result in another cell.

Exercise in Excel

As a first straight I suggest you display the module bar and the Visual Basic, so you can add a button to it and associate an action. In the example the values are in cells “E7” and “E8”, the result will show it in the cell “E10”.

Sub Multiply_Clic()

    Dim a, b As Double

    a = Worksheets("Sheet1").Cells(7, 5)
    b = Worksheets("Sheet1").Cells(8, 5)

    a = a * b

    Worksheets("Sheet1").Cells(10, 5) = a

End Sub

Many of you will say to me then that you can accomplish this task in a better way, without the need to press a button in Excel. Certainly, I reply, but this was only the first example to show you how to program with VBA in Excel.

Categories: Office
Tags: Excel
giampy107:
X

Cookies Policy

We use cookies to personalize content and ads, provide social media features and analyze our traffic. We also share information about your use of our site with our web analytics, advertising and social media partners who may combine it with other information you have provided to them or that they have collected based on your use of theirs. services.

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings