ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   select all cells in sheet (https://www.excelbanter.com/excel-programming/325376-select-all-cells-sheet.html)

DJH

select all cells in sheet
 
What is the correct syntax to select all the cells in a sheet (so I can then
format the cells)? Manually, I would use shift-ctrl-end, selecting from A1
to the last cell.



Rowan[_2_]

select all cells in sheet
 
With Cell A1 active

Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

Regards
Rowan

"djh" wrote:

What is the correct syntax to select all the cells in a sheet (so I can then
format the cells)? Manually, I would use shift-ctrl-end, selecting from A1
to the last cell.



Dave Peterson[_5_]

select all cells in sheet
 
You don't usually need to select the cells to work with them.

with activesheet.usedrange.cells
.numberformat = "General"
end with

(If row 1 isn't used and if column A isn't used, it won't be included.)

With ActiveSheet
With .Range("a1", .UsedRange)
.NumberFormat = "general"
End With
End With

Will get A1 to the bottom right corner.

Or all the cells
with activesheet.cells
.numberformat = "General"
end with



djh wrote:

What is the correct syntax to select all the cells in a sheet (so I can then
format the cells)? Manually, I would use shift-ctrl-end, selecting from A1
to the last cell.


--

Dave Peterson


All times are GMT +1. The time now is 05:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com