Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How can i make a macro run all sheets ?


I work with a lot of macros . Sometimes i have excel books with lots of
sheets ( and i mean lots - sometimes more than 20 ) . How can i make my
macros run all sheets in same time ?


--
andrei
------------------------------------------------------------------------
andrei's Profile: http://www.thecodecage.com/forumz/me...hp?userid=1056
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=154390

Microsoft Office Help

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How can i make a macro run all sheets ?

You can refer to all worksheets like this:

Sub test()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
Debug.Print sht.Name
Next
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How can i make a macro run all sheets ?


Actually i have this macro . It concatenates rows if given keyword is
found in A column and puts result in C column . That chages should i do
to run all sheets once ? Now i have to change the name of the sheet
every time i need to run macro



Code:
--------------------

Sub testme()
Dim myCell As Range
Dim myRng As Range
Dim DestCell As Range
Dim myWord As String

myWord = "house"

With Worksheets("Sheet1")
Set myRng = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
Set DestCell = .Range("C1")
End With

For Each myCell In myRng.Cells
With myCell
If LCase(.Value) = LCase(myWord) Then
DestCell.Value = .Value & .Offset(0, 1).Value
Set DestCell = DestCell.Offset(1, 0)
End If
End With
Next myCell

End Sub

--------------------


--
andrei
------------------------------------------------------------------------
andrei's Profile: http://www.thecodecage.com/forumz/me...hp?userid=1056
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=154390

Microsoft Office Help

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default How can i make a macro run all sheets ?

Sub testme()
Dim myCell As Range
Dim myRng As Range
Dim DestCell As Range
Dim myWord As String
Dim wksht As Worksheet

myWord = "house"
For Each wksht In ActiveWorkbook.Sheets
With wksht
Set myRng = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
Set DestCell = .Range("C1")
End With

For Each myCell In myRng.Cells
With myCell
If LCase(.Value) = LCase(myWord) Then
DestCell.Value = .Value & .Offset(0, 1).Value
Set DestCell = DestCell.Offset(1, 0)
End If
End With
Next myCell
Next wksht

End Sub


Gord Dibben MS Excel MVP

On Mon, 16 Nov 2009 15:35:23 +0000, andrei
wrote:


Actually i have this macro . It concatenates rows if given keyword is
found in A column and puts result in C column . That chages should i do
to run all sheets once ? Now i have to change the name of the sheet
every time i need to run macro



Code:
--------------------

Sub testme()
Dim myCell As Range
Dim myRng As Range
Dim DestCell As Range
Dim myWord As String

myWord = "house"

With Worksheets("Sheet1")
Set myRng = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
Set DestCell = .Range("C1")
End With

For Each myCell In myRng.Cells
With myCell
If LCase(.Value) = LCase(myWord) Then
DestCell.Value = .Value & .Offset(0, 1).Value
Set DestCell = DestCell.Offset(1, 0)
End If
End With
Next myCell

End Sub

--------------------


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
Macro to Select All Sheets and Make Change to Footer Karin Excel Discussion (Misc queries) 2 September 20th 08 10:01 PM
Make macro available to all sheets Bill_S Excel Discussion (Misc queries) 3 April 10th 08 07:55 PM
Make global Macro/Add-in for all active Workbooks/Sheets SunRace Excel Programming 6 January 28th 08 12:40 PM
Is it possible to make an excel macro to work with all sheets? Mr. Pie Excel Programming 10 September 3rd 07 11:46 PM
how do you make macro run across protected sheets ace Excel Discussion (Misc queries) 1 April 13th 05 09:00 AM


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