Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic Range Selection

I have a spreadsheet that goes to say column S and several thousand rows.
I would like the program to request a user to highlight a Range for example
A50:A55 (this is a variable range however the selections would always be in
column A. Based on the user selected range the range would be named and
program would execute code for the adjacent cells in the selected range.

Can you please assist with this code?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Dynamic Range Selection

Dim myRng as range
dim myCell as range

set myrng = nothing
on error resume next
set myrng _
= application.inputbox(prompt:="select a single range",type:=8).areas(1)
on error goto 0

if myrng is nothing then
msgbox "ok. Quitting"
exit sub
end if

set myrng = myrng.entirerow.columns(1)

for each mycell in myrng.cells
msgbox mycell.address & vblf & mycell.offset(0,3).address
next mycell

=====
there really isn't a reason to give the range a name to work with it.


Phil P wrote:

I have a spreadsheet that goes to say column S and several thousand rows.
I would like the program to request a user to highlight a Range for example
A50:A55 (this is a variable range however the selections would always be in
column A. Based on the user selected range the range would be named and
program would execute code for the adjacent cells in the selected range.

Can you please assist with this code?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Dynamic Range Selection

Thanks so much for your help Dave. I will put your code in program and work
with it. Sorry for the duplicate message. I received a message failed
notification when I originally posted.

"Dave Peterson" wrote:

Dim myRng as range
dim myCell as range

set myrng = nothing
on error resume next
set myrng _
= application.inputbox(prompt:="select a single range",type:=8).areas(1)
on error goto 0

if myrng is nothing then
msgbox "ok. Quitting"
exit sub
end if

set myrng = myrng.entirerow.columns(1)

for each mycell in myrng.cells
msgbox mycell.address & vblf & mycell.offset(0,3).address
next mycell

=====
there really isn't a reason to give the range a name to work with it.


Phil P wrote:

I have a spreadsheet that goes to say column âœS❠and several thousand rows.
I would like the program to request a user to highlight a Range for example
A50:A55 (this is a variable range however the selections would always be in
column A. Based on the user selected range the range would be named and
program would execute code for the adjacent cells in the selected range.

Can you please assist with this code?


--

Dave Peterson

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
Dynamic Range Selection Using VBA TEK Excel Discussion (Misc queries) 2 January 23rd 10 04:55 AM
Dynamic selection of a range Sören_Marodören Excel Programming 2 December 5th 07 01:28 PM
Need Help on Dynamic Range Selection anshu[_2_] Excel Discussion (Misc queries) 5 July 12th 07 07:52 AM
Dynamic range selection Fernando Ronci Excel Programming 1 August 4th 04 10:37 PM
Dynamic Range Selection Todd Huttenstine Excel Programming 4 May 5th 04 08:54 PM


All times are GMT +1. The time now is 02:52 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"