Excel Selection in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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"
 
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)).numberformat = "0"
end with

Robin Hammond
www.enhanceddatasystems.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top