Results 1 to 16 of 16

Thread: Sleeper: If and Statement based on one cell and

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,970
    I'm guessing that you want to start with a sheet like Start in the attached.
    I've made a copy of that sheet (Start (2)) to experiment on, select that sheet then run the macro blah (Alt+F8 on the keyboard then-double click on the blah macro).
    Compare with Sheet1.

    The macro:
    Sub blah()
    For Each are In Cells.SpecialCells(xlCellTypeConstants, 23).Areas
      If are.Rows.Count > 1 And are.Columns.Count > 3 Then
        Set mycell = are.Cells(are.Rows.Count, 3).Offset(2)
        If mycell.Offset(1).Value = "" And mycell.Value = "" Then
          mycell.Formula = "=(" & are.Cells(are.Rows.Count, 4).Address & "-" & are.Cells(1, 4).Address & ")/(" & are.Cells(are.Rows.Count, 2).Address & "-" & are.Cells(1, 2).Address & ")"
          fr = mycell.Row
          lr = are.Row + are.Rows.Count - 1
          are.Columns(4).Offset(, 1).FormulaR1C1 = "=RC[-1]-(((RC[-3]-R" & lr & "C[-3])*R" & fr & "C[-2])+R" & lr & "C[-1])"
          If are.Column > 6 Then are.Columns(4).Offset(, 2).FormulaR1C1 = "=(RC[-2]-RC[-8])/(RC[-3]-RC[-9])"
        End If
      End If
    Next are
    End Sub
    It's a start.
    Lots of things could make it go wrong.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •