您好我正在尝试转换excel中的链接,我正在为此目的编写一个宏。我唯一的问题是pastespecial选项不起作用。
Sub Transpose_Links()
'
' Transpose_Links Macro
'
' Hotkey: Ctrl+m
'
此时我的剪贴板上有我要移植的单元格 然后我将它们粘贴到当前位置。然后可以改变它们 所以链接保留在单元格的内容中
Sheets("wincc").Select
ActiveSheet.Paste Link:=True
Selection.Replace What:="=", Replacement:="xxx", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Application.CutCopyMode = True
Selection.Cut
再次剪切更改后的信息后,我想询问粘贴它们的范围 这成功是因为我已经尝试改变范围的值并且它起作用。我也试过使用普通的粘贴,但这也没有用。我尝试在网站上搜索类似的问题,但我找不到。我还在msdn.microsoft.com上检查了这个方法,但我没有提供太多信息。
Dim rRange As Range
Set rRange = Application.InputBox(Prompt:= _
"Please select a range with your Mouse to be bolded.", _
Title:="SPECIFY RANGE", Type:=8)
rRange.PasteSpecial Paste = xlPasteAll, Operation = xlNone, SkipBlanks = _
False, Transpose:=True
rRange.Replace What:="xxx", Replacement:="=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
答案 0 :(得分:1)
试试这个:
Sub Transpose_Links()
Dim rRange As Range
' Transpose_Links Macro
'
' Hotkey: Ctrl+m
'
Sheets("wincc").Select
ActiveSheet.Paste Link:=True
Selection.Replace What:="=", Replacement:="xxx", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Application.CutCopyMode = True
Selection.Cut
Set rRange = Application.InputBox(Prompt:= _
"Please select a range with your Mouse to be bolded.", _
Title:="SPECIFY RANGE", Type:=8)
Selection.Copy
rRange.PasteSpecial Paste:=xlPasteAll, Operation:=xlPasteSpecialOperationNone, SkipBlanks:=False, Transpose:=True
rRange.Replace What:="xxx", Replacement:="=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub