Sub RangeSwap()
Dim inputRangeType As String
Dim inputRange1 As String
Dim inputRange2 As String
Dim input1
Dim input2
Dim inputRow1 As Long
Dim inputRow2 As Long
' Ask them what they want to move
inputRangeType = InputBox("Enter C for cell or R for row", "ENTER WHAT TO SWAP")
' Decide what to do
Select Case UCase(inputRangeType)
' Cell swap steps
Case "C"
' Prompt for cell address entries
On Error GoTo cell_error
inputRange1 = InputBox("Enter first cell address", "FIRST CELL")
inputRange2 = InputBox("Enter second cell address", "SECOND CELL")
' Capture values
input1 = Range(inputRange1)
input2 = Range(inputRange2)
' Switch values
Range(inputRange1) = input2
Range(inputRange2) = input1
On Error GoTo 0
MsgBox "Cell swap completed!"
' Row swap steps
Case "R"
' Prompt for row entries
On Error GoTo row_error
inputRow1 = InputBox("Enter first row number", "FIRST ROW")
inputRow2 = InputBox("Enter second row number", "SECOND ROW")
If inputRow1 < 1 Or inputRow1 > Rows.Count Then GoTo row_error
If inputRow1 < 2 Or inputRow2 > Rows.Count Then GoTo row_error
' Copy rows
If inputRow2 > inputRow1 Then
Rows(inputRow2 + 1).Insert Shift:=xlDown
Rows(inputRow1).Copy Destination:=Rows(inputRow2 + 1)
Rows(inputRow2).Copy Destination:=Rows(inputRow1)
Rows(inputRow2).Delete
Else
Rows(inputRow1 + 1).Insert Shift:=xlDown
Rows(inputRow2).Copy Destination:=Rows(inputRow1 + 1)
Rows(inputRow1).Copy Destination:=Rows(inputRow2)
Rows(inputRow1).Delete
End If
On Error GoTo 0
MsgBox "Row swap complete"
Case Else
MsgBox "That is not a valid entry", vbOKOnly, "ERROR!"
End Select
Exit Sub
cell_error:
MsgBox "You have entered an invalid cell address!"
Exit Sub
row_error:
MsgBox "You have entered an invalid row number!"
Exit Sub
End Sub