使用VBA交换excel中单元格内的值

使用VBA交换excel中单元格内的值,excel,vba,cell,Excel,Vba,Cell,这让我对自己的处境产生了一个小小的怀疑。如何使用VBA交换单元格内的值 For Example If the value in the cell is 0080 I want it to be swapped to 8000 or if the value is 1567 it should be swapped to 6715 如果有人能帮忙,请选择一个单元格并: Sub swap() With ActiveCell .Value = Right(.Value, 2)

这让我对自己的处境产生了一个小小的怀疑。如何使用VBA交换单元格内的值

For Example
If the value in the cell is 0080 I want it to be swapped to 8000
or if the value is 1567 it should be swapped to 6715
如果有人能帮忙,请选择一个单元格并:

Sub swap()
    With ActiveCell
        .Value = Right(.Value, 2) & Left(.Value, 2)
    End With
End Sub
WS.Range(“A5”).Value=Right$(WS.Range(“A5”).Value,2)和left$(WS.Range(“A5”).Value,2)


它在我的Excel上工作。谢谢。

到目前为止,您做了什么?向我们展示您的尝试,以便我们能够帮助您。
Sub Replace()
    ActiveCell.Replace What:="0080^t", Replacement:="8000^t", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Cells.Replace What:="0080", Replacement:="8000", LookAt:=xlWhole, SearchOrder _
        :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
End Sub