是否可以通过VBA恢复Excel中的pastepecial动作的参数?
有没有办法“听” Excel中的“聆听the the the the the the the the the the the the the the the the the the pastepecial命令及其参数? 我正在编写一个VBA代码来管理范围。PasteSpecial方法,并意识到我需要一种方法来知道用户定义的操作的转置参数是对还是错,因此我可以相应地对待源数据。 奥斯科派对,因为我不知道何时transpose是正确的,所以下面的这条代码实际上无效。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim UndoList As String
Application.ScreenUpdating = False
Application.EnableEvents = False
If Application.CommandBars("Standard").Controls("&Undo").Enabled = True Then
UndoList = Application.CommandBars("Standard").Controls("&Undo").List(1)
MsgBox (UndoList & "!")
If Left(UndoList, 5) = "Paste " Or UndoList = "Paste special" Then
If UndoList = "Paste special" Then
If Transpose Then
MsgBox ("Paste Transposed Values")
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
'and other stuff
Exit Sub
Else
MsgBox ("Paste Values")
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'and other stuff
Exit Sub
End If
ElseIf Left(UndoList, 5) = "Paste" Then
MsgBox ("Just Paste formats")
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False
Exit Sub
Else
MsgBox ("choose another method")
'Application.Undo
Exit Sub
End If
Else
Exit Sub
End If
UndoList = ""
End If
End Sub
is there a way to "listen' to the PasteSpecial command and its parameters in excel?
I'm writing a vba code to manage the Range.PasteSpecial method and realized I need a way to know if the Transpose parameter of the action defined by the user is true or false, so I can treat the source data accordingly.
Offcourse, since I don't know when Transpose is TRUE, this piece of code below does not really work.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim UndoList As String
Application.ScreenUpdating = False
Application.EnableEvents = False
If Application.CommandBars("Standard").Controls("&Undo").Enabled = True Then
UndoList = Application.CommandBars("Standard").Controls("&Undo").List(1)
MsgBox (UndoList & "!")
If Left(UndoList, 5) = "Paste " Or UndoList = "Paste special" Then
If UndoList = "Paste special" Then
If Transpose Then
MsgBox ("Paste Transposed Values")
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
'and other stuff
Exit Sub
Else
MsgBox ("Paste Values")
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'and other stuff
Exit Sub
End If
ElseIf Left(UndoList, 5) = "Paste" Then
MsgBox ("Just Paste formats")
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False
Exit Sub
Else
MsgBox ("choose another method")
'Application.Undo
Exit Sub
End If
Else
Exit Sub
End If
UndoList = ""
End If
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论