I am trying to swap the content between two cells in Excel based on the content of a third cell. So, I have a column in Excel - say Column C. I want to swap the values of the corresponding cells in Columns A and B based on whether there is an "S" in the corresponding cell in Column C. I am no expert in VB, but I have these two macros that I am trying to re-work. The first one is in the sheet module and is as follows:
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub If Not Application.Intersect(Range("C1"), Target) Is Nothing Then If IsNumeric(Target.Value) And Target.Value = "S" Then Call swap End If End If End Sub
The second is in the Standard module and is as follows:
Sub swap() Dim cellVal cellVal = ActiveCell.Value ActiveCell.Value = ActiveCell.Offset(0, 1).Value ActiveCell.Offset(0, 1).Value = cellVal End Sub
It's not working for some reason. Can anyone help me out? I think it's because I have ".Count" in the first macro and I'm looking for an "S", but I dunno what to change it to. Any help would be much appreciated.