Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default MACRO Assistance Required

Hi some help would be appreciated - I use this MACRO to copy a cell
group from one sheet (called clipboard) to another sheet (pointslist)
at a position determined by the highlighted cell on the destination
sheet:

Sub CopyPlant()
Dim x As Variant, strRange As String

Set x = ActiveCell
strRange = InputBox("Plant Config?", "Range to Copy", "Plant")
Worksheets("Clipboard").Range(strRange).Copy (x)
End Sub

Various different groups of cells have been given 'names' on the
clipboard. When I execute the Macro I am asked to enter the 'name',
the macro then copies the requisite cell group to the points list.

I want to automate this further and give each group a seperate macro
which can be activated by a button. Initially I thought this would be
simple - just create a macro which runs the existing macro, types in
the requisite plant name and job done, but you dont seem to be able to
run a macro within a macro. Any ideas anyone? Best Regards, Andy
Fletcher.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default MACRO Assistance Required

Hi,
Set up this sub..

Sub CopyPlant(strRange as string)
Worksheets("Clipboard").Range(*strRange).Copy ActiveCell
End Sub

Then call it like this..

Sub Button1Click()
Let strRange = InputBox("Plant Config?", "Range to Copy", "Plant")
CopyPlants strRange
End Sub

assign Button1 to Button1Click (assuming it is a Forms Button).
Untested but should work (i think). The principle is there; pasing a
variable to a common routine...
Hth,
OJ

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default MACRO Assistance Required

Hi,
I'm not sure I was thinking when I wrote this....

You have buttons to represent each named cell? Is that right?
OJ

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default MACRO Assistance Required

Do you mean?

Sub CopyPlant()
Dim x As Variant, strRange As String

Set x = ActiveCell
strRange = InputBox("Plant Config?", "Range to Copy", "Plant")
Select Case strRange
Case "Value1": Macro1
Case "Value2": Macro2
Case "Value3": Macro3
End Select
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Fletcher" wrote in message
om...
Hi some help would be appreciated - I use this MACRO to copy a cell
group from one sheet (called clipboard) to another sheet (pointslist)
at a position determined by the highlighted cell on the destination
sheet:

Sub CopyPlant()
Dim x As Variant, strRange As String

Set x = ActiveCell
strRange = InputBox("Plant Config?", "Range to Copy", "Plant")
Worksheets("Clipboard").Range(strRange).Copy (x)
End Sub

Various different groups of cells have been given 'names' on the
clipboard. When I execute the Macro I am asked to enter the 'name',
the macro then copies the requisite cell group to the points list.

I want to automate this further and give each group a seperate macro
which can be activated by a button. Initially I thought this would be
simple - just create a macro which runs the existing macro, types in
the requisite plant name and job done, but you dont seem to be able to
run a macro within a macro. Any ideas anyone? Best Regards, Andy
Fletcher.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default MACRO Assistance Required

Thanks for the prompt response guys. I could use custom buttons but
thought the tidier solution would be to assign each macro to an item in
a drop down list.

Thx. Andy



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default MACRO Assistance Required

Assuming the item selected in the dropdown is the name of the range to copy:

Sub DropDown1_Click()
Dim x As Range, strRange As String
Dim sName as String, drpdwn as DropDown
sName = Application.Caller
set drpdwn = Activesheet.DropDowns(sName)
if drpdwn.ListIndex < 0 then
strRange = drpdwn.List(drpdwn.ListIndex)
Set x = ActiveCell
Worksheets("Clipboard").Range(strRange).Copy x
End if
End Sub

Assumes a dropdown (combobox) from the Forms Toolbar.

You shouldn't put x in parentheses - unless you want to refer to the value
stored in the cell referenced by x. Apparently it has been working for you,
but there are situations where this will cause an error. In VBA you put
arguments in parentheses only when the function is returning a value that
will be used or if you use the CALL statement. Copy is a method, but I
would still follow the convention.

--
Regards,
Tom Ogilvy


"Fletch" wrote in message
ups.com...
Thanks for the prompt response guys. I could use custom buttons but
thought the tidier solution would be to assign each macro to an item in
a drop down list.

Thx. Andy



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
Formula assistance required J.Scargill[_2_] Excel Worksheet Functions 3 April 6th 10 10:54 AM
Assistance required Anthony Excel Discussion (Misc queries) 1 June 2nd 06 11:14 PM
Formula assistance required!!! Don Excel Discussion (Misc queries) 4 February 22nd 05 08:34 PM
Macro assistance required please [email protected] Excel Programming 0 November 7th 03 08:30 AM
Excel Macro Program assistance required David Moen Excel Programming 3 November 5th 03 06:07 AM


All times are GMT +1. The time now is 10:17 PM.

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"