Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Modify Ron Debruin Macro - Prompting for range


Hello,

I am trying to modify Ron Debruin's CopyRangeFromMultiWorksheets macro.
Specifically I want the macro to prompt the user for a range vs. going in and
tweaking the macro each time based on what range is needed.

For instance, the user will first need to consolidate range A6:C11 from 50+
worksheets. The next time they will need to consolidate A16:C22 from the
same set.

The code that Ron has is
'Fill in the range that you want to copy
Set CopyRng = sh.Range("b6:C11")

I tried to use different variations of the following:
Set CopyRng = Application.InputBox _
(Prompt:="Range to copy:", Type:=8)

The macro fails.

Thanks in advance for helping me modify this macro.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default Modify Ron Debruin Macro - Prompting for range


The input box will return a text string
Dim TextRng as string
Set TextRng = Application.InputBox (Prompt:="Range to copy:", Type:=8)
'for example, B3:B27

Set CopyRng = sh.Range(TextRng)

Aircode, but that should give you a good start. You may want to put in an
error checker, in case the entry doesn't correspond to a valid range
("A43A54" or "G7:G")

HTH
Keith

"ScottMsp" wrote:

Hello,

I am trying to modify Ron Debruin's CopyRangeFromMultiWorksheets macro.
Specifically I want the macro to prompt the user for a range vs. going in and
tweaking the macro each time based on what range is needed.

For instance, the user will first need to consolidate range A6:C11 from 50+
worksheets. The next time they will need to consolidate A16:C22 from the
same set.

The code that Ron has is
'Fill in the range that you want to copy
Set CopyRng = sh.Range("b6:C11")

I tried to use different variations of the following:
Set CopyRng = Application.InputBox _
(Prompt:="Range to copy:", Type:=8)

The macro fails.

Thanks in advance for helping me modify this macro.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Modify Ron Debruin Macro - Prompting for range


How about using the refEdit control on a user form? Pop it up, let the user
select the range, and then grab the range text string from the refEdit
control to use in Ron's logic.

HTH,

Eric

"ScottMsp" wrote:

Hello,

I am trying to modify Ron Debruin's CopyRangeFromMultiWorksheets macro.
Specifically I want the macro to prompt the user for a range vs. going in and
tweaking the macro each time based on what range is needed.

For instance, the user will first need to consolidate range A6:C11 from 50+
worksheets. The next time they will need to consolidate A16:C22 from the
same set.

The code that Ron has is
'Fill in the range that you want to copy
Set CopyRng = sh.Range("b6:C11")

I tried to use different variations of the following:
Set CopyRng = Application.InputBox _
(Prompt:="Range to copy:", Type:=8)

The macro fails.

Thanks in advance for helping me modify this macro.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Modify Ron Debruin Macro - Prompting for range


Dim CopyRng as range

set copyrng = nothing
on error resume next
set copyrng = application.inputbox(Prompt:="Select something", type:=8)
on error goto 0

if copyrng is nothing then
msgbox "user hit cancel, what should happen here?"
exit sub '????
end if




ScottMsp wrote:

Hello,

I am trying to modify Ron Debruin's CopyRangeFromMultiWorksheets macro.
Specifically I want the macro to prompt the user for a range vs. going in and
tweaking the macro each time based on what range is needed.

For instance, the user will first need to consolidate range A6:C11 from 50+
worksheets. The next time they will need to consolidate A16:C22 from the
same set.

The code that Ron has is
'Fill in the range that you want to copy
Set CopyRng = sh.Range("b6:C11")

I tried to use different variations of the following:
Set CopyRng = Application.InputBox _
(Prompt:="Range to copy:", Type:=8)

The macro fails.

Thanks in advance for helping me modify this macro.


--

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
Slow Macro - Delete Row Based on Condition-Modified Ron DeBruin Ma ScottMSP Excel Programming 3 January 28th 09 09:33 PM
modification of auto-multiple workbook macro, Ron DeBruin (Copy4) SteveDB1 Excel Programming 10 June 20th 08 04:17 AM
Excel Macro Prompting crusse04 Excel Programming 2 June 12th 08 09:11 PM
modify a macro to apply to a specific range of cells Dave F Excel Discussion (Misc queries) 2 April 25th 07 03:00 AM
Prompting 'Save As' in an Excel Macro Glenn Gooding Excel Programming 1 December 2nd 04 09:49 AM


All times are GMT +1. The time now is 01:22 AM.

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

About Us

"It's about Microsoft Excel"