It is pretty much the same way. At its simplest you could follow this pattern
Code:
Sub GetStyled()
Dim sSty As String
sSty = Selection.Style
If sSty = "Normal" Then
Selection.Style = "Heading 2"
Else
Selection.Style = "Heading 3"
End If
End Sub
If your selection includes multiple styles (eg more than one paragraph selected or character style + paragraph style) then you may need to complicate the code to get the right results.