User selection

  • Thread starter Thread starter Samir
  • Start date Start date
S

Samir

Hi Everyone,
Need some help to finish a project. The procedure requests
user to select a column in a worksheet by either selecting
the entire column or just selecting a single cell in that
column. The idea is that once selection is made, data
would be generated from that column. However, I am not
sure how do I determine which column in the work sheet was
selected by the user. Any help is appreciated. Thanks in
advance.
 
Try something like this :

Set rngSelection = Application.InputBox( _
Prompt:="Select cell(s) (use CTRL key to select
more than one)", _
Title:="your title", _
Default:=ActiveCell.Address, _
Type:=8)

this will return a range object after the user has
selected something

Rgds

Rog
 
Samir,

If you want just the column number, use code like

Dim ColNum As Integer
ColNum = ActiveCell.Column

If you want a Range reference to the column, use

Dim ColRng As Range
Set ColRng = ActiveCell.EntireColumn
' or
Set ColRng = Application.Intersect(ActiveSheet.UsedRange,
ActiveCell.EntireColumn)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Back
Top