Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default For each workbook


I need two versions of my code below, which now replaces a text in all
sheets of an open workbook.

WHAT I NEED IN ADDITION TO THIS IS:

1. Replace in all open workbooks,
2. Replace in all workbooks in specified folder....



THIS IS MY CODE:

Private Sub cmd_OK_Click()
Dim Morg
Dim Mto

Morg = Lbud.TextBox_org
Mto = Lbud.TextBox_to



Dim Sht As Worksheet



For Each Sht In Worksheets
Sht.Cells.Replace What:=Morg, _
Replacement:=Mto, LookAt:=xlPart, MatchCase:=False
Next





Unload Lbud
End Sub


--
Ctech
------------------------------------------------------------------------
Ctech's Profile: http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=481942

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default For each workbook

Hi Ctech

see below

WHAT I NEED IN ADDITION TO THIS IS:

1. Replace in all open workbooks,


try this

sub openWorkBooks()
Dim wn As Window

For Each wn In Windows
wn.Activate
call cmd_OK_Click ' run your rotine
Next
end sub



2. Replace in all workbooks in specified folder....


Sub folder()

Dim nFiles As Long
Dim Filename As String

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
'select all or some excel files
.AllowMultiSelect = True
.Show

' Display paths of each file selected
For nFiles = 1 To .SelectedItems.Count

Filename = .SelectedItems(nFiles)
Workbooks.Open Filename ' open wookbooks

Call cmd_OK_Click 'run your rotine

Application.DisplayAlerts = False
ActiveWorkbook.Close True 'save and close
Application.DisplayAlerts = True

Next

End With

End Sub


THIS IS MY CODE:

Private Sub cmd_OK_Click()
Dim Morg
Dim Mto

Morg = Lbud.TextBox_org
Mto = Lbud.TextBox_to



Dim Sht As Worksheet



For Each Sht In Worksheets
Sht.Cells.Replace What:=Morg, _
Replacement:=Mto, LookAt:=xlPart, MatchCase:=False
Next





Unload Lbud
End Sub


--
Ctech
------------------------------------------------------------------------
Ctech's Profile:
http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=481942



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
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


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

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"