Quantcast
Channel: OKWAVE 最新質問(Visual Basic/257)【本日】
Viewing all articles
Browse latest Browse all 6510

マクロでセル内の改行を削除する方法

$
0
0
システムから抽出したCSVファイルをExcelで読み込むと同時に不要な列を削除します。 その際、セル内の改行が邪魔で行がずれてしまいます。 すでに記述したコードを生かしながら、セル内の改行を削除する方法はありますでしょうか? 以下がコードです Private Sub CommandButton1_Click() '//Sheet7のセルをクリア Sheets("Sheet7").Cells.Clear '// Sheet7のA1にissue_export.csvを読み込み With Sheets("Sheet7").QueryTables.Add(Connection:="TEXT;C:\*****.csv", Destination:=Sheets("sheet7").Range("A1")) Dim R As Range For Each R In Sheets("Sheet7").Range("A1") R.Value = Trim(Replace(R.Value, vbCr, "")) R.Value = Trim(Replace(R.Value, vbLf, "")) Next R .Name = "test" .FieldNames = True .RowNumbers = False .Refresh BackgroundQuery:=False .RefreshPeriod = 0 .RefreshOnFileOpen = False .PreserveFormatting = True .AdjustColumnWidth = True .FillAdjacentFormulas = False .RefreshStyle = xlInsertEntireRows .SavePassword = False .SaveData = True .TextFilePromptOnRefresh = False .TextFileParseType = xlDelimited .TextFileStartRow = 1 .TextFilePlatform = 65001 .TextFilePlatform = xlWindows .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = False .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = True .TextFileSpaceDelimiter = False .TextFileTrailingMinusNumbers = False .TextFileColumnDataTypes = Array(9, 9, 9, 9, 2, 9, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) .Refresh .Parent.Names(.Name).Delete .Delete End With End Sub

Viewing all articles
Browse latest Browse all 6510

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>