+ Reply to Thread
Results 1 to 4 of 4

If statement in macro

  1. #1
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Happyville, USA
    MS-Off Ver
    365
    Posts
    294

    If statement in macro

    Hi,

    I'm trying to get the formula below to run in my macro. This is a report I'll be running on a weekly basis and the number of blanks in column I will change every week. I'm trying to get the macro to apply the formula at the first blank but I'm having some issues. I've been kicking around the Dim LastRow as long but I keep getting various error messages. In a nutshell what I'm looking for is the macro to read the first blank in column I, then if AE = 7 or 11I want it to poplulate column I with FedEx Weeky Charge.


    =IF(AND(OR(AE2=7,AE2=11),I2=""), "FedEx Weekly Charge", "")

    Thanks for all your help.

    Eddie

  2. #2
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Happyville, USA
    MS-Off Ver
    365
    Posts
    294
    Bump.

    Thanks

  3. #3
    Dave Peterson
    Guest

    Re: If statement in macro

    I'm not sure I understand...

    But maybe...

    Option Explicit
    Sub testme()
    Dim NextRow As Long

    With ActiveSheet
    NextRow = .Cells(.Rows.Count, "I").End(xlUp).Row + 1
    with .cells(NextRow, "I")
    .Formula _
    = "=IF(AND(OR(AE2=7,AE2=11),I2=""""),""FedEx Weekly
    Charge"","""")"
    '.value = .value '????
    End With
    End Sub


    punter wrote:
    >
    > Hi,
    >
    > I'm trying to get the formula below to run in my macro. This is a
    > report I'll be running on a weekly basis and the number of blanks in
    > column I will change every week. I'm trying to get the macro to apply
    > the formula at the first blank but I'm having some issues. I've been
    > kicking around the Dim LastRow as long but I keep getting various error
    > messages. In a nutshell what I'm looking for is the macro to read the
    > first blank in column I, then if AE = 7 or 11I want it to poplulate
    > column I with FedEx Weeky Charge.
    >
    > =IF(AND(OR(AE2=7,AE2=11),I2=""), "FedEx Weekly Charge", "")
    >
    > Thanks for all your help.
    >
    > Eddie
    >
    > --
    > punter
    >
    > ------------------------------------------------------------------------
    > punter's Profile: http://www.excelforum.com/member.php...fo&userid=2044
    > View this thread: http://www.excelforum.com/showthread...hreadid=553220


    --

    Dave Peterson

  4. #4
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Happyville, USA
    MS-Off Ver
    365
    Posts
    294
    Thanks Dave. I found a work around but your way seems to be much cleaner and most likely quicker. I'm going to test it in a little bit.

    Thanks

    Eddie

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1