ET2005/WPS 表格 2005 「選擇性貼上」缺「連接(&)」運算,導致重複前綴(如地址)需手工輸入。用 VBA 增加右鍵選單「選擇性貼上──連接」:
Sub 選擇性貼上_連接()
Dim rng As String, NewSht As String, OldSht As String
Dim texts, i As Byte, ans As Byte
If ActiveSheet.ProtectContents Then MsgBox "工作表已保護", 64, "提示": Exit Sub
On Error GoTo endd
rng = Selection.Address
OldSht = ActiveSheet.Name
Application.DisplayAlerts = False
Worksheets.Add
NewSht = ActiveSheet.Name
Range("A1").Select
ActiveSheet.Paste
If ActiveSheet.UsedRange.Count > 1 Then MsgBox "只能連接單一儲存格值", 64, "andysky": GoTo endd
texts = Selection.Text
Application.ScreenUpdating = True
Sheets(OldSht).Select
ans = InputBox("1:連接於目標之前" & Chr(10) & "2:連接於目標之後", "連接方式", 1)
For i = 1 To Selection.Count
If ans = 1 Then Selection(i) = texts & Selection(i)
If ans = 2 Then Selection(i) = Selection(i) & texts
Next
endd:
Worksheets(NewSht).Delete
End Sub
Private Sub Workbook_Open()
With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, Before:=4, Temporary:=True)
.Caption = "選擇性貼上__連接(&Paste)"
.OnAction = "選擇性貼上_連接"
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("CELL").Reset
End Sub






圖 1-6:原版缺連接運算 → VBA 實作 → 存範本 → 右鍵選單出現 → 實測前綴/後綴連接
VBA 賦予 WPS 表格無限擴充性,預設功能不夠用時,自己寫一個最貼心。