Cells and Range Property in VBA
With the Cells property, you can reference any object inside a worksheet, where you can make changes or retrieve the value. This is…
With the Cells property, you can reference any object inside a worksheet, where you can make changes or retrieve the value. This is…
The range object in VBA represents a range of cells on a worksheet. It can consist of multiple cells, as well as a…
If you want to use the VBA code to open a workbook in read-only mode, you have to follow these steps.
1 2 3 4 5 6 7 8 |
Sub OpenWorkbook() Dim my_wb As Workbook Dim file_path As String file_path = "C:\excel_file.xlsx" Set my_wb = Workbooks.Open(Filename:=file_path, ReadOnly:=True) End Sub |
In order to save a workbook in VBA, use Alt + F11 and enter the following code.
1 2 3 |
Sub SaveWorkbook() ActiveWorkbook.Save End Sub |
This procedure will save the…
In this lesson, I’ll show you two methods you can use to read files. The first one will read a file line by…
In this lesson, I presented a few ways to get the last column number. The first methods are easy, but then the code…
In order to count rows in Excel, you have to use the VBA code. Open VBA Editor with Alt + F11. We are…
In order to sort columns in a table with VBA, you have to create one. This is the table we are going to…
In order to sort data inside a range in VBA, you have to use the following code.
1 2 3 |
Sub Sort() Range("A1:A10").Sort key1:=Range("A1"), order1:=xlAscending, Header:=xlNo End Sub |
This code will give you…
In Excel, you can use VBA to draw borders around cells, ranges, and selected ranges. First, open the VBA Editor (Alt + F11)…