Consulting

Results 1 to 4 of 4

Thread: VBA help loop until & IF formula

  1. #1

    VBA help loop until & IF formula

    Hello, thanks for looking

    I have a worksheet with a column full of dates.
    I have a cell with a control date
    I also need a column with a formula

    Column B (starting at cell 5) has dates. The column updates weekly and the number of rows is dynamic. This is where the loop comes in.

    C2 has a static date

    Column F (starting at cell 5) would have the formula
    =IF ($C $2>B5, "over", "in")

    I have tried to Frankenstein different code from forums but Excel doesn't seem to like the formula.

    Help is greatly appreciated.

  2. #2
    VBAX Regular
    Joined
    Jan 2018
    Posts
    55
    Location
    Hi, Spaceballs. I wonder if this is what you want but try it.

    Sub Macro1()
        Range("F5:F" & Rows.Count).ClearContents
        Range("F5").Formula = "=IF($C$2>B5,""over"",""in"")"
        Range("F5:F" & Range("B" & Rows.Count).End(xlUp).Row).FillDown
    End S
    ub

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,872
    or combine the last two lines:
    Sub Macro2()
        Range("F5:F" & Rows.Count).ClearContents
        Range("F5:F" & Range("B" & Rows.Count).End(xlUp).Row).Formula = "=IF($C$2>B5,""over"",""in"")"
    End Sub
    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.

  4. #4
    VBAX Regular
    Joined
    Jan 2018
    Posts
    55
    Location
    Yeah, I've learned from you.
    Thanks p45cal!

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
  •