| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

「Excel VBA すべてのシートに対して一括置換」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
(ページの作成:「==Excel VBA すべてのシートに対して一括置換== [Excel][Excel VBA] {{amazon|4798122084}} ====すべてのシートに対して一括置換する====…」)
 
 
(同じ利用者による、間の3版が非表示)
1行目: 1行目:
==Excel VBA すべてのシートに対して一括置換==
+
==[[Excel VBA すべてのシートに対して一括置換]]==
[Excel][Excel VBA]
+
[[Excel]] | [[Excel VBA]] |
  
 
{{amazon|4798122084}}
 
{{amazon|4798122084}}
  
 
====すべてのシートに対して一括置換する====
 
====すべてのシートに対して一括置換する====
  Sub AllReplace()
+
  Sub All[[R]]eplace()
 
      
 
      
 
     Dim f      As String
 
     Dim f      As String
 
     Dim t      As String
 
     Dim t      As String
 
     Dim i      As Integer
 
     Dim i      As Integer
     Dim sht    As Excel.Worksheet
+
     Dim sht    As [[Excel]].Worksheet
 
      
 
      
 
     f = InputBox("置換対象文字列を入力してください")
 
     f = InputBox("置換対象文字列を入力してください")
 
      
 
      
     If Trim$(f) <> "" Then
+
     If Trim$(f) &lt;&gt; "" Then
 
         t = InputBox("置換後文字列を入力してください")
 
         t = InputBox("置換後文字列を入力してください")
 
     End If
 
     End If
29行目: 29行目:
 
         End If
 
         End If
 
   
 
   
         sht.Cells.Replace What:=f, Replacement:=t, LookAt:= _
+
         sht.Cells.[[R]]eplace What:=f, [[R]]eplacement:=t, LookAt:= _
         xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False
+
         xlPart, SearchOrder:=xlBy[[R]]ows, MatchCase:=False, MatchByte:=False
 
     Next
 
     Next
 
   
 
   
 
     Call MsgBox("完了")
 
     Call MsgBox("完了")
 
  End Sub
 
  End Sub

2020年2月16日 (日) 04:25時点における最新版

Excel VBA すべてのシートに対して一括置換

Excel | Excel VBA |

すべてのシートに対して一括置換する

  1. Sub AllReplace()
  2. Dim f As String
  3. Dim t As String
  4. Dim i As Integer
  5. Dim sht As Excel.Worksheet
  6. f = InputBox("置換対象文字列を入力してください")
  7. If Trim$(f) <> "" Then
  8. t = InputBox("置換後文字列を入力してください")
  9. End If
  10.  
  11. If Trim$(t) = "" Then
  12. Exit Sub
  13. End If
  14. For i = 1 To ActiveWorkbook.Sheets.Count
  15. Set sht = ActiveWorkbook.Sheets(i)
  16. If sht.Name = f Then
  17. sht.Name = t
  18. End If
  19.  
  20. sht.Cells.Replace What:=f, Replacement:=t, LookAt:= _
  21. xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False
  22. Next
  23.  
  24. Call MsgBox("完了")
  25. End Sub