Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lee Lee is offline
external usenet poster
 
Posts: 33
Default Select column at run-time

Is there a way to prompt a user to select a column and
that selection be passed to a sub-routine as a variable?
I think it would be fairly easy to do this where users
type in an input box, but I would like for them to
actually be able to select the column instead of typing.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Select column at run-time

Try this

Sub test()
Dim mycell As Range
Set mycell = Application.InputBox( _
prompt:="Select a range", Type:=8)

mycell.Copy Sheets("Sheet2").Range("A1")

End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Lee" wrote in message ...
Is there a way to prompt a user to select a column and
that selection be passed to a sub-routine as a variable?
I think it would be fairly easy to do this where users
type in an input box, but I would like for them to
actually be able to select the column instead of typing.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Select column at run-time

Just to elaborate, this allows the user to select using the mouse or by
typing in the range in the inputbox.

--
Regards,
Tom Ogilvy

"Ron de Bruin" wrote in message
...
Try this

Sub test()
Dim mycell As Range
Set mycell = Application.InputBox( _
prompt:="Select a range", Type:=8)

mycell.Copy Sheets("Sheet2").Range("A1")

End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Lee" wrote in message

...
Is there a way to prompt a user to select a column and
that selection be passed to a sub-routine as a variable?
I think it would be fairly easy to do this where users
type in an input box, but I would like for them to
actually be able to select the column instead of typing.





  #4   Report Post  
Posted to microsoft.public.excel.programming
Lee Lee is offline
external usenet poster
 
Posts: 33
Default Select column at run-time

Thanks. This sort of works. It does place the cell
reference in the input box. However, what I'm trying to
do is sort the whole spreadhseet based on the cell
selected. It is passing the value of the cell along when
in fact I just need to pass the cell number as a
reference.

-----Original Message-----
Try this

Sub test()
Dim mycell As Range
Set mycell = Application.InputBox( _
prompt:="Select a range", Type:=8)

mycell.Copy Sheets("Sheet2").Range("A1")

End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Lee" wrote in

message ...
Is there a way to prompt a user to select a column and
that selection be passed to a sub-routine as a variable?
I think it would be fairly easy to do this where users
type in an input box, but I would like for them to
actually be able to select the column instead of typing.



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Select column at run-time

It passes a reference to the cell. You can use that to do your sorting.

Dim mycell As Range
Set mycell = Application.InputBox( _
prompt:="Select a range", Type:=8)
Call Mysort( mycell)


Sub Mysort(rng as Range)
cell.Sort Key1:=rng, Order1:=xlAscending
End Sub


When you don't know the answer, it is nicer to ask people how their
suggestion could be used to do this or do that rather than tell them it
can't be used for what you want. And after all, your original question said
nothing about sorting, only about selecting a range with a mouse and passing
it to a subroutine.


--
Regards,
Tom Ogilvy


"Lee" wrote in message
...
Thanks. This sort of works. It does place the cell
reference in the input box. However, what I'm trying to
do is sort the whole spreadhseet based on the cell
selected. It is passing the value of the cell along when
in fact I just need to pass the cell number as a
reference.

-----Original Message-----
Try this

Sub test()
Dim mycell As Range
Set mycell = Application.InputBox( _
prompt:="Select a range", Type:=8)

mycell.Copy Sheets("Sheet2").Range("A1")

End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Lee" wrote in

message ...
Is there a way to prompt a user to select a column and
that selection be passed to a sub-routine as a variable?
I think it would be fairly easy to do this where users
type in an input box, but I would like for them to
actually be able to select the column instead of typing.



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Shortcut to select column with data in previous column TJAC Excel Discussion (Misc queries) 1 July 10th 07 06:12 PM
How do I select onlu one cell at a time? Phil Excel Discussion (Misc queries) 2 June 6th 07 06:07 PM
select detail in column B if column A = date Dan B Excel Worksheet Functions 0 September 18th 06 04:46 PM
select a different range each time Don Guillett[_4_] Excel Programming 6 August 1st 03 05:16 PM


All times are GMT +1. The time now is 06:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"