Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Assign Macro To Button At Runtime

Hi ,

I am creating a button thru macro and assign a function named Refresh.
It is executing well. While opening the workbook, there is an error pops up
"Macro name is not valid, check the name"

But macro is executing . IS there any way to find out what is the problem

My macro is in Module1 .

Sub refresh

end sub
OR
function refresh
End function
which is correct

but for both having issue


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Assign Macro To Button At Runtime

Hi

You don't share the creation/assignment code, but try assigning to

ThisWorkbook.Name & "!Refresh"

and see if it helps.

HTH. best wishes Harald

"swami" skrev i melding
...
Hi ,

I am creating a button thru macro and assign a function named Refresh.
It is executing well. While opening the workbook, there is an error pops

up
"Macro name is not valid, check the name"

But macro is executing . IS there any way to find out what is the problem

My macro is in Module1 .

Sub refresh

end sub
OR
function refresh
End function
which is correct

but for both having issue




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Assign Macro To Button At Runtime


If you have a button created by the Forms toolbox, then you can assign the
macro at runtime as this example demonstrates:

Sub test()
ActiveSheet.Shapes("Button 1").OnAction = ThisWorkbook.Name & "!Refresh"
End Sub

Public Function Refresh()
MsgBox "Hello World"
End Function

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"swami" wrote in message
...
Hi ,

I am creating a button thru macro and assign a function named Refresh.
It is executing well. While opening the workbook, there is an error pops
up
"Macro name is not valid, check the name"

But macro is executing . IS there any way to find out what is the problem

My macro is in Module1 .

Sub refresh

end sub
OR
function refresh
End function
which is correct

but for both having issue




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
Assign a macro to a button totofab Excel Discussion (Misc queries) 4 December 13th 07 06:16 PM
How do I Assign Macro to a button? BellExcel Charts and Charting in Excel 4 May 20th 05 07:21 PM
Assign macro to button Bob Phillips[_6_] Excel Programming 0 May 24th 04 04:27 PM
Assign macro to button Frank Kabel Excel Programming 0 May 24th 04 04:03 PM
Assign button to run macro jamie85[_5_] Excel Programming 8 February 3rd 04 01:44 PM


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