2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【メモ】ExcelをPDF化したときに、改行位置に空白スペースのようなの四角が表示されるのを解消する

Posted at
vba
Sub Replace()

On Error GoTo ERR

    Dim OpenFileName As String
    OpenFileName = Application.GetOpenFilename("Microsoft Excelブック,*.xls*")
    If OpenFileName <> "False" Then
        Workbooks.Open OpenFileName
    End If
    
    Dim i As Integer
    Dim sheetCnt As Integer

    sheetCnt = ActiveWorkbook.Sheets.Count
    
    i = 1
    
    Do While i < sheetCnt
    
        Worksheets(i).Cells.Replace What:=vbCrLf, Replacement:=vbLf, LookAt:=xlPart, ReplaceFormat:=False
    
        i = i + 1
    Loop
    
GoTo OWARI

ERR:
MsgBox ("エラーが発生しました。エラーの原因がわからない場合はお手数ですが、作成者までご連絡ください。")
Exit Sub

OWARI:
MsgBox ("処理が完了しました。")
    
    
End Sub
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?