Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Lista Forumurilor Pe Tematici
|
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login
POZE MRRRR'S FORUM (VIEW ONLY)
Nu sunteti logat.
|
Nou pe simpatie: Coco11 25 ani
| Femeie 25 ani Constanta cauta Barbat 27 - 65 ani |
|
TRaP
Moderator
Inregistrat: acum 6 ani
Postari: 787
|
|
Adapted from source to work only on a specific sheet, named the same in all workbooks. Source loops through all sheets in each file.
Sub ReplaceStringInExcelFiles()
Dim MyFile As String Dim FilePath As String Dim orig As String Dim news As String Dim wb As Workbook, ws As Worksheet
orig = "2023" news = "2024"
FilePath = "D:\2024" MyFile = Dir(FilePath & "*.xls*")
Do While Len(MyFile) > 0 Set wb = Workbooks.Open(FilePath & MyFile) Set ws = wb.Worksheets("data")
With wb.Worksheets("data") ws.Range("A1:A31").Cells.Replace what:=orig, _ Replacement:=news, _ lookAt:=xlPart, SearchOrder:=xlByRows, _ MatchCase:=False End With ActiveWorkbook.Close savechanges:=True MyFile = Dir Loop
End Sub |
Source:
|
|
pus acum 1 an |
|