Menggunakan makro, saya bergabung dengan 2 set kolom terpisah dengan titik dua menggunakan fungsi sederhana, seperti =A2&":"&B2
Ini berfungsi dengan baik sampai sampai ke baris terakhir, di mana makro menambahkan dua sel tambahan masing-masing hanya dengan :
di dalamnya. Sepertinya makro dipilih secara otomatis melewati bidang yang berisi data dan bergabung dengan konten sel kosong dengan :
.
Saya telah meninjau makro beberapa kali dan tidak melihat apa yang menyebabkannya. Dapatkah seseorang melihat ini untuk saya?
Sub NetworkStatisticsFilter()
'
' NetworkStatisticsFilter Macro
' Format and Filter Data from Get-NetStatTCP to simplify port discovery
'
'
'Suppress alerts
'
Application.DisplayAlerts = False
'
'Delete empty header rows that resulted from Get-NetStatTCP export
'
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Rows("2:2").Select
Selection.Delete Shift:=xlUp
'
'Text-to-Columns, space-delimited
'
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)), _
TrailingMinusNumbers:=True
'
'Join LocalAddress & LocalPort with a ":" then copy results and replace both columns w/a paste-value
'
Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("D1").Select
ActiveCell.FormulaR1C1 = "SRC"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]&"":""&RC[-1]"
Range("C2").Select
Selection.AutoFill Destination:=Range("C2:C77")
Range("C2:C77").Select
Selection.Copy
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("A:C").Select
Range("C1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
'
'Join RemoteAddress & RemotePort with a ":" then copy results and replace both columns w/a paste-value
'
Columns("D:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("E1").Select
ActiveCell.FormulaR1C1 = "DST"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]&"":""&RC[-1]"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D77")
Range("D2:D77").Select
Selection.Copy
Range("E2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("B:D").Select
Range("D1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
'
'Auto-fit columns
'
Columns("A:D").Select
Columns("A:D").EntireColumn.AutoFit
'
'Auto-filter loopback address/port combinations and delete resulting rows
'
Columns("A:A").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$A$79").AutoFilter Field:=1, Criteria1:="=127.0.0.1*", Operator:=xlFilterValues
ActiveSheet.UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete
ActiveSheet.ShowAllData
'
'Remove duplicate values in DST column
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$C$67").RemoveDuplicates Columns:=2, Header:=xlYes
ActiveWindow.SmallScroll Down:=-9
'
'Allow Alerts
'
Application.DisplayAlerts = True
End Sub