Select All Cells in Excel Using VBA – VBA Tutorials

Select All Cells

Introduction/Problem Statement

In this blog, we will talk about how to select the entire worksheet in a workbook using VBA. To select all cells of a worksheet we can use it. cells property of the worksheet.

Solutions

This code will select all cells of an active worksheet.

select the all cells

Sub KDataScience_SelectAllCellsOfWorksheet()
    Sheet4.Activate
    Cells.Select

End Sub

If we want to select all cells of a worksheet which is not an active worksheet then we need to first activate the worksheet then select the entire cells. If we do not activate the worksheet then it will show error.

select all cells of a worksheet

Sub KDataScience_SelectEntireSheet()
    
    'To activate sheet
    Worksheets("sheet4").Activate
    'To select the entire cells of activesheet
    Cells.Select

End Sub

Conclusion:

If you want to select entire cells of a worksheet then you can use any code shown above (according to one need).

Leave a Reply

Your email address will not be published. Required fields are marked *