title: How to add conditions to my recorded macro?
body: <p>I have recorded the macro below, which is used to auto-transfer data that I enter into one worksheet to another worksheet when I run the macro. At present, I would have to record a macro for each new worksheet in this workbook and run each separate macro depending upon which sheet I need the new data transferred to. I would like to know how to add conditions to this macro that will automatically decide which worksheet to send the new data to, based on what text is in column G of the original worksheet. There are four different text phrases that might be contained in column G. Any help would be greatly appreciated!</p>
  
  <pre><code>Sub over_90_days()
  '
  ' over_90_days Macro
  ' transfer info from all terms to over 90 days sheet
  '
  
  '
      ActiveCell.Offset(0, -7).Columns("A:A").EntireColumn.Select
      Selection.End(xlDown).Select
  End Sub
  
  
  Sub update()
  '
  ' update Macro
  ' move new data to a different worksheet
  '
  
  '
      Range("Table1[[#Headers],[Name, Last]]").Select
      Selection.End(xlDown).Select
      Range("A74:B74").Select
      Selection.Copy
      Sheets("90 DAYS OR LESS").Select
      Range("A2").Select
      Selection.End(xlDown).Select
      ActiveCell.Offset(1, 0).Range("A1").Select
      ActiveSheet.Paste
      Sheets("ALL TERMS").Select
      ActiveCell.Offset(0, 2).Range("A1").Select
      Application.CutCopyMode = False
      Selection.Copy
      Sheets("90 DAYS OR LESS").Select
      ActiveCell.Offset(0, 2).Range("A1").Select
      ActiveSheet.Paste
      Sheets("ALL TERMS").Select
      ActiveCell.Offset(0, 1).Range("A1").Select
      Application.CutCopyMode = False
      Selection.Copy
      Sheets("90 DAYS OR LESS").Select
      ActiveCell.Offset(0, 1).Range("A1").Select
      ActiveSheet.Paste
      Sheets("ALL TERMS").Select
      ActiveCell.Offset(0, 2).Range("A1").Select
      Application.CutCopyMode = False
      Selection.Copy
      Sheets("90 DAYS OR LESS").Select
      ActiveCell.Offset(0, 1).Range("A1").Select
      ActiveSheet.Paste
      ActiveWindow.SmallScroll Down:=3
      ActiveSheet.Paste
      Application.CutCopyMode = False
      ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
      Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
  End Sub
  </code></pre>
  
  <p>So here's my second less that glorious attempt:</p>
  
  <pre><code>Sub update()
  
  Set MainSheet = ThisWorkbook.Worksheets("ALL TERMS")
  Set Sheet1 = ThisWorkbook.Worksheets("TERM PRE OJT")
  Set Sheet2 = ThisWorkbook.Worksheets("TERM POST OJT")
  Set Sheet3 = ThisWorkbook.Worksheets("90 DAYS OR LESS")
  Set Sheet4 = ThisWorkbook.Worksheets("OVER 90 DAYS")
  Dim Rnge2 As Range
  Set Rnge2 = "A2"
  
  Dim i As Integer
  For i = 1 To 50
  MyValue = MainSheet.Cells(i, 7).Value
  
  If MyValue = "orientation only" Then
  
  ActiveCell.Offset(0, -6).Select
  Range(ActiveCell, ActiveCell.Offset(0, 4)).Copy
  Sheet1.Select
  Rnge2.Select
  ActiveCell.Offset(1, 0).Select
  ActiveSheet.Paste
  ActiveCell.Offset(1, 0).Select       'move down one row
  
  ElseIf MyValue = "ojt only" Then
  
  ActiveCell.Offset(0, -6).Select
  Range(ActiveCell, ActiveCell.Offset(0, 4)).Copy
  Sheet2.Select
  Rnge2.Select
  ActiveCell.Offset(1, 0).Select
  ActiveSheet.Paste
  ActiveCell.Offset(1, 0).Select
  
  ElseIf MyValue = "90 days or less" Then
  
  ActiveCell.Offset(0, -6).Select
  Range(ActiveCell, ActiveCell.Offset(0, 4)).Copy
  Sheet3.Select
  Rnge2.Select
  ActiveCell.Offset(1, 0).Select
  ActiveSheet.Paste
  ActiveCell.Offset(1, 0).Select
  
  ElseIf MyValue = "over 90 days" Then
  
  ActiveCell.Offset(0, -6).Select
  Range(ActiveCell, ActiveCell.Offset(0, 4)).Copy
  Sheet1.Select
  Rnge2.Select
  ActiveCell.Offset(1, 0).Select
  ActiveSheet.Paste
  ActiveCell.Offset(1, 0).Select
  
  End If
  Next
  
  End Sub
  </code></pre>
  
  <p>it doesn't work, and I have no idea why.</p>