VBA Set Column Width or Row Height - learnit

Home Top Ad

Post Top Ad

Wednesday, May 12, 2021

VBA Set Column Width or Row Height

VBA Set Column Width or Row Height

VBA Set Column Width or Row Height

What is Visual Basic for Applications (VBA)?

Visual Basic for Applications (VBA) is an event-driven programming language implemented by Microsoft to develop Office applications. VBA helps to develop automation processes, Windows API, and user-defined functions. It also enables you to manipulate the user interface features of the host applications.


Before we go into further details, let us look at what computer programming is in a layman's language. Assume you have a maid. If you want the maid to clean the house and do the laundry. You tell her what to do using let us say English and she does the work for you. As you work with a computer, you will want to perform certain tasks. Just as if you told the maid to do the house chores, you can also tell the computer to do the tasks for you.


The process of telling the computer what you want it to do for you is what is known as computer programming. Just as you used English to tell the maid what to do, you can also use English like statements to tell the computer what to do. The English like statements fall in the category of high-level languages. VBA is a high-level language that you can use to bend excel to your all-powerful will.


Why Use VBA?

VBA enables you to use English like statements to write instructions for creating various applications. VBA is easy to learn, and it has easy to use User Interface in which you just have to drag and drop the interface controls. It also allows you to enhance Excel functionality by making it behave the way you want.

Excel Row heights and Columns widths can be changed in VBA by setting the .RowHeight and .ColumnWidth properties.

Example


Set Column Width with VBA
Macro to set the column width of Columns B2

Sub ColumnWidth()
Range("B2").Columnwidth=10
End Sub


Sub ColumunWidth()
Range("B2").Columns.columnwidth=20
End Sub


Set Row Height with VBA

Macro to set the row height of Row 2

Sub RowHeight()
Range("B2").RowHeight=10
End Sub

Sub RowHeight()
Range("B2").RowHeight=10
End Sub

Please Watching My Video is Below

No comments:

Post a Comment

Post Top Ad