A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Can anyone



 
 
Thread Tools Display Modes
  #1  
Old May 3rd, 2009, 12:16 PM posted to microsoft.public.excel.worksheet.functions
[email protected]
external usenet poster
 
Posts: 27
Default Can anyone

Hi All,

I got one macro, which I pasted in my module but if I want to run that
macro,
the macro name is not visible. Or how do check the result to be
appeared in immediate window ?

Sub LoopThruSheetsBookX(BookX$)
Dim sh As Sheet
For Each sh In Workbooks(BookX$)
Debug.Print sh.Name
Next sh
End Sub
  #2  
Old May 3rd, 2009, 12:38 PM posted to microsoft.public.excel.worksheet.functions
Joel
external usenet poster
 
Posts: 2,855
Default Can anyone

When you pasted the code into VBA you either put the code on a worksheet or
thisworkbook. You need to put your code into a mode. view the Project
Explorer from the VBA (select Prject Explorer from the View Menu). You will
see there is a sheet for each spreadsheet and thisworkbook. You can also
create Modules. go to Insert Module to add the module. then move you code
from the shet to the module. You can double click on any of these VBA
objects to view the code.

" wrote:

Hi All,

I got one macro, which I pasted in my module but if I want to run that
macro,
the macro name is not visible. Or how do check the result to be
appeared in immediate window ?

Sub LoopThruSheetsBookX(BookX$)
Dim sh As Sheet
For Each sh In Workbooks(BookX$)
Debug.Print sh.Name
Next sh
End Sub

  #3  
Old May 3rd, 2009, 12:54 PM posted to microsoft.public.excel.worksheet.functions
Jacob Skaria
external usenet poster
 
Posts: 5,952
Default Can anyone

From Visual Basic Editor windows; from Insert menu insert a module and paste
your code. Save and close. Get back to workbook. Check macros..
--
If this post helps click Yes
---------------
Jacob Skaria


" wrote:

Hi All,

I got one macro, which I pasted in my module but if I want to run that
macro,
the macro name is not visible. Or how do check the result to be
appeared in immediate window ?

Sub LoopThruSheetsBookX(BookX$)
Dim sh As Sheet
For Each sh In Workbooks(BookX$)
Debug.Print sh.Name
Next sh
End Sub

  #4  
Old May 3rd, 2009, 02:17 PM posted to microsoft.public.excel.worksheet.functions
Simon Lloyd[_226_]
external usenet poster
 
Posts: 1
Default Can anyone


;331376 Wrote:
Hi All,

I got one macro, which I pasted in my module but if I want to run that
macro,
the macro name is not visible. Or how do check the result to be
appeared in immediate window ?

Sub LoopThruSheetsBookX(BookX$)
Dim sh As Sheet
For Each sh In Workbooks(BookX$)
Debug.Print sh.Name
Next sh
End Sub


Maybe this will help
*How to add and run a Macro*1. *Copy* the macro above pressing
the keys *CTRL+C*
2. Open your workbook
3. Press the keys *ALT+F11* to open the Visual Basic Editor
4. Press the keys *ALT+I* to activate the *Insert menu*
5. *Press M* to insert a *Standard Module*
6. *Paste* the code by pressing the keys *CTRL+V*
7. Make any custom changes to the macro if needed at this time.
8. *Save the Macro* by pressing the keys *CTRL+S*
9. Press the keys *ALT+Q* to exit the Editor, and return to Excel.

*To Run the Macro...*
To run the macro from Excel, open the workbook, and press *ALT+F8* to
display the *Run Macro Dialog*. Double Click the macro's name to *Run*
it.


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (
http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=92616

  #5  
Old May 3rd, 2009, 03:14 PM posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick
external usenet poster
 
Posts: 2,496
Default Can anyone

Macros that take arguments are not 'runnable" other than through other code.
For example, you can pass a workbook object to your sub by using one of the
line from something like this:

Sub Test()
LoopThruSheetsBookX ActiveWorkbook
LoopThruSheetsBookX Workbooks("Name.xls")
End Sub

Sub LoopThruSheetsBookX(BookX$)
.....


HTH,
Bernie
MS Excel MVP
wrote in message
...
Hi All,

I got one macro, which I pasted in my module but if I want to run that
macro,
the macro name is not visible. Or how do check the result to be
appeared in immediate window ?

Sub LoopThruSheetsBookX(BookX$)
Dim sh As Sheet
For Each sh In Workbooks(BookX$)
Debug.Print sh.Name
Next sh
End Sub


  #6  
Old May 3rd, 2009, 03:39 PM posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick
external usenet poster
 
Posts: 2,496
Default Can anyone

I'm sorry, I ignored your string use - though BookX was an object:

Sub Test()
LoopThruSheetsBookX ActiveWorkbook.Name
LoopThruSheetsBookX "Name.xls"
End Sub.

Sub LoopThruSheetsBookX(BookX As String)
Dim sh As Sheet
For Each sh In Workbooks(BookX)
Debug.Print sh.Name
Next sh
End Sub

Bernie

"Bernie Deitrick" deitbe @ consumer dot org wrote in message
...
Macros that take arguments are not 'runnable" other than through other
code. For example, you can pass a workbook object to your sub by using one
of the line from something like this:

Sub Test()
LoopThruSheetsBookX ActiveWorkbook
LoopThruSheetsBookX Workbooks("Name.xls")
End Sub

Sub LoopThruSheetsBookX(BookX$)
....


HTH,
Bernie
MS Excel MVP
wrote in message
...
Hi All,

I got one macro, which I pasted in my module but if I want to run that
macro,
the macro name is not visible. Or how do check the result to be
appeared in immediate window ?

Sub LoopThruSheetsBookX(BookX$)
Dim sh As Sheet
For Each sh In Workbooks(BookX$)
Debug.Print sh.Name
Next sh
End Sub



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.