Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Allow Macro to Work by Selecting Cell Description

Could you please help me with this matter?

I have a three buttons with their respectively macros in one worksheet. The
macros names are Wood, Metal and Plastic.
In addition, I have a pull out list located in the cell A1 with the
following description:
Wood
Metal
Plastic

I would like to know if I can just run the macros name with its
respectively name pulled out in the list.

For example, I pick in the cell A1 Wood I just want the macro Wood be able
to run after I click it. If I click the button with the macro Metal and/or
the macro Plastic I want to get a window message €śPick the Wood Button€ť.

For example, I pick in the cell A1 Metal I just want the macro Metal be able
to run after I click it. If I click the button with the macro Wood and/or the
macro Plastic I want to get a window message €śPick the Metal Button€ť.

For example, I pick in the cell A1 Plastic I just want the macro Plastic be
able to run after I click it. If I click the button with the macro Wood
and/or the macro Metal I want to get a window message €śPick the Plastic
Button€ť.

Thanks in advance.
Maperalia

  #2   Report Post  
Posted to microsoft.public.excel.programming
PA PA is offline
external usenet poster
 
Posts: 101
Default Allow Macro to Work by Selecting Cell Description

There are several ways to do this. Here's two:

First:
Create a new function in the same module as your macros

Private Function ValidMaterialSelected(ByVal sMacroMaterial As String) As
Boolean
Dim sMaterialSelected As String

sMaterialSelected = Range("a1").Value

If sMacroMaterial = sMaterialSelected Then
ValidMaterialSelected = True
Else
MsgBox "Pick the " & sMaterialSelected & " button."
ValidMaterialSelected = False
End If
End Function

Then, at the beginning of each of your macros, add the following code:

if not ValidSelectedMaterial( [the name of your macro ie Wood, Metal,
Plastic]) then
exit sub
end if

Second way:

Create only one button on your sheet that would trigger the following code:

application.run range("a1")

This will launch the macro whose name is in A1.

By the way, I didn't test the code.

PA




"Maperalia" wrote:

Could you please help me with this matter?

I have a three buttons with their respectively macros in one worksheet. The
macros names are Wood, Metal and Plastic.
In addition, I have a pull out list located in the cell A1 with the
following description:
Wood
Metal
Plastic

I would like to know if I can just run the macros name with its
respectively name pulled out in the list.

For example, I pick in the cell A1 Wood I just want the macro Wood be able
to run after I click it. If I click the button with the macro Metal and/or
the macro Plastic I want to get a window message €śPick the Wood Button€ť.

For example, I pick in the cell A1 Metal I just want the macro Metal be able
to run after I click it. If I click the button with the macro Wood and/or the
macro Plastic I want to get a window message €śPick the Metal Button€ť.

For example, I pick in the cell A1 Plastic I just want the macro Plastic be
able to run after I click it. If I click the button with the macro Wood
and/or the macro Metal I want to get a window message €śPick the Plastic
Button€ť.

Thanks in advance.
Maperalia

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Allow Macro to Work by Selecting Cell Description

sPA;
Thanks very much. Your code runs excellent.

Maperalia

"PA" wrote:

There are several ways to do this. Here's two:

First:
Create a new function in the same module as your macros

Private Function ValidMaterialSelected(ByVal sMacroMaterial As String) As
Boolean
Dim sMaterialSelected As String

sMaterialSelected = Range("a1").Value

If sMacroMaterial = sMaterialSelected Then
ValidMaterialSelected = True
Else
MsgBox "Pick the " & sMaterialSelected & " button."
ValidMaterialSelected = False
End If
End Function

Then, at the beginning of each of your macros, add the following code:

if not ValidSelectedMaterial( [the name of your macro ie Wood, Metal,
Plastic]) then
exit sub
end if

Second way:

Create only one button on your sheet that would trigger the following code:

application.run range("a1")

This will launch the macro whose name is in A1.

By the way, I didn't test the code.

PA




"Maperalia" wrote:

Could you please help me with this matter?

I have a three buttons with their respectively macros in one worksheet. The
macros names are Wood, Metal and Plastic.
In addition, I have a pull out list located in the cell A1 with the
following description:
Wood
Metal
Plastic

I would like to know if I can just run the macros name with its
respectively name pulled out in the list.

For example, I pick in the cell A1 Wood I just want the macro Wood be able
to run after I click it. If I click the button with the macro Metal and/or
the macro Plastic I want to get a window message €śPick the Wood Button€ť.

For example, I pick in the cell A1 Metal I just want the macro Metal be able
to run after I click it. If I click the button with the macro Wood and/or the
macro Plastic I want to get a window message €śPick the Metal Button€ť.

For example, I pick in the cell A1 Plastic I just want the macro Plastic be
able to run after I click it. If I click the button with the macro Wood
and/or the macro Metal I want to get a window message €śPick the Plastic
Button€ť.

Thanks in advance.
Maperalia

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Allow Macro to Work by Selecting Cell Description

Hi

When a button is pressed, check if the corresponding text is selected in A1,
if not display message and exit sub. Otherwise continue code.

Private Sub cbPlastic_Click()
If Range("A1").Value < "Plastic" Then
msg = MsgBox("Pick the " & Range("A1").Value & " button!",
vbExclamation, "Wrong Button")
Exit Sub
End If
'Your code
End Sub

Hopes this helps.

---
Per

"Maperalia" skrev i meddelelsen
...
Could you please help me with this matter?

I have a three buttons with their respectively macros in one worksheet.
The
macros names are Wood, Metal and Plastic.
In addition, I have a pull out list located in the cell A1 with the
following description:
Wood
Metal
Plastic

I would like to know if I can just run the macros name with its
respectively name pulled out in the list.

For example, I pick in the cell A1 Wood I just want the macro Wood be able
to run after I click it. If I click the button with the macro Metal and/or
the macro Plastic I want to get a window message €śPick the Wood Button€ť.

For example, I pick in the cell A1 Metal I just want the macro Metal be
able
to run after I click it. If I click the button with the macro Wood and/or
the
macro Plastic I want to get a window message €śPick the Metal Button€ť.

For example, I pick in the cell A1 Plastic I just want the macro Plastic
be
able to run after I click it. If I click the button with the macro Wood
and/or the macro Metal I want to get a window message €śPick the Plastic
Button€ť.

Thanks in advance.
Maperalia


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Allow Macro to Work by Selecting Cell Description

Per;
Thanks you very much. It is working PERFECTLY!!!!!!

Maperalia

"Per Jessen" wrote:

Hi

When a button is pressed, check if the corresponding text is selected in A1,
if not display message and exit sub. Otherwise continue code.

Private Sub cbPlastic_Click()
If Range("A1").Value < "Plastic" Then
msg = MsgBox("Pick the " & Range("A1").Value & " button!",
vbExclamation, "Wrong Button")
Exit Sub
End If
'Your code
End Sub

Hopes this helps.

---
Per

"Maperalia" skrev i meddelelsen
...
Could you please help me with this matter?

I have a three buttons with their respectively macros in one worksheet.
The
macros names are Wood, Metal and Plastic.
In addition, I have a pull out list located in the cell A1 with the
following description:
Wood
Metal
Plastic

I would like to know if I can just run the macros name with its
respectively name pulled out in the list.

For example, I pick in the cell A1 Wood I just want the macro Wood be able
to run after I click it. If I click the button with the macro Metal and/or
the macro Plastic I want to get a window message €śPick the Wood Button€ť.

For example, I pick in the cell A1 Metal I just want the macro Metal be
able
to run after I click it. If I click the button with the macro Wood and/or
the
macro Plastic I want to get a window message €śPick the Metal Button€ť.

For example, I pick in the cell A1 Plastic I just want the macro Plastic
be
able to run after I click it. If I click the button with the macro Wood
and/or the macro Metal I want to get a window message €śPick the Plastic
Button€ť.

Thanks in advance.
Maperalia





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
Selecting a cell during a macro Sue Excel Programming 3 February 21st 08 02:46 PM
Selecting a cell doesn't work????? biosci[_3_] Excel Programming 3 April 6th 06 01:27 AM
Macro - Selecting Next Available Cell cappuccine Excel Programming 11 November 3rd 05 10:19 PM
Data Validation does not work when selecting another cell. Simon Jefford Excel Discussion (Misc queries) 5 June 29th 05 11:10 PM
Macro selecting the last used cell does not work Kaj Pedersen Excel Programming 1 November 4th 03 10:25 PM


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