1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| Option Explicit
Sub ReplaceAndTranspose()
Dim FromChars As Variant
Dim ToChars As Variant
Dim iCtr As Long
FromChars = Array(Chr(28))
ToChars = Array(Chr(124))
If UBound(FromChars) <> UBound(ToChars) Then
MsgBox "design error--make from/to match"
Exit Sub
End If
For iCtr = LBound(FromChars) To UBound(FromChars)
ActiveSheet.Cells.replace What:=FromChars(iCtr), _
Replacement:=ToChars(iCtr), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Next iCtr
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="|", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
1)), TrailingMinusNumbers:=True
Cells.Select
Cells.EntireColumn.AutoFit
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
Cells.Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1:B200").Select
Selection.Copy
Sheets.Add
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub |
Partager