ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Selection in VBA (https://www.excelbanter.com/excel-programming/321893-excel-selection-vba.html)

JeepNC

Excel Selection in VBA
 
What is the proper method for doing a selection that is the equivalent of
manually using the ctrl, shift and down arrow keys to select from the
starting point to the end of the data? I have a macro that works and tried
to modify that code to work, but have not been successful. The pointer moves
to cell K2 but the selection doesn't work. After it is selected I'm planning
to change the format of the column of data.

Thanks,

xls is an object that is the worksheet selected from the excel object.

xls.Range("K2").Select
xls.Range(Selection, Selection.End(xlDown)).Select
xls.Selection.NumberFormat = "0"

Robin Hammond[_2_]

Excel Selection in VBA
 
Jeep,

you are better off avoiding selection statements completely. This will
format the range you want directly.

with xls
.range(.range("k2"),.range("k2").End(xlDown)).numb erformat = "0"
end with

Robin Hammond
www.enhanceddatasystems.com

"JeepNC" wrote in message
...
What is the proper method for doing a selection that is the equivalent of
manually using the ctrl, shift and down arrow keys to select from the
starting point to the end of the data? I have a macro that works and
tried
to modify that code to work, but have not been successful. The pointer
moves
to cell K2 but the selection doesn't work. After it is selected I'm
planning
to change the format of the column of data.

Thanks,

xls is an object that is the worksheet selected from the excel object.

xls.Range("K2").Select
xls.Range(Selection, Selection.End(xlDown)).Select
xls.Selection.NumberFormat = "0"





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

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