Microsoft Excel is known to be an application software used in performing most arithmetic and logical workouts, however, Ms Excel has the ability to use features such as built-in commands to help the user perform a specific task as required.
To perform macro programming in Excel, you can use the Visual Basic for Applications (VBA) editor. The VBA editor is a programming environment that is built into Excel.
To open the VBA editor, click on the “Developer” tab and then click on the “Visual Basic” button.
Once the VBA editor is open, you can start writing code to automate tasks in Excel.
For example, the following code will create a new spreadsheet and enter the numbers 1 to 10 into the first column:
Sub CreateSpreadsheet()
Dim wb As Workbook
Dim ws As Worksheet
‘Create a new workbook.
Set wb = Workbooks.Add
‘Apply and fix in a new worksheet to the active workbook
Set ws = wb.Worksheets.Add
‘Enter the numbers 1 to 10 into the first column of the worksheet.
For i = 1 To 10
ws.Cells(i, 1).Value = i
Next i
‘Save the workbook.
wb.SaveAs “C:\path\to\file.xlsx”
‘Close the workbook.
wb.Close
End Sub
About Author
Discover more from SURFCLOUD TECHNOLOGY
Subscribe to get the latest posts sent to your email.