+ Reply to Thread
Results 1 to 3 of 3

Help: Nested If/And Function formula to VB code

  1. #1
    RAP
    Guest

    Help: Nested If/And Function formula to VB code

    I have an inefficient, but working, nested if-and worksheet function formula
    that I need to put into a macro. I almost got "do-looped" to death today.
    Any help or direction would be most appreiciated. - Randy


    Range("H11").Select (Activecell)
    ActiveCell.Formula =
    "=IF(AND(B11=24,B18=24,B25=24,B32=24,B39=24,B46=24,B53=24,B60=24),TRUE,FALSE)"

    If ActiveCell = True Then

    Else:


  2. #2
    Earl Kiosterud
    Guest

    Re: Nested If/And Function formula to VB code

    RAP,

    If Range("B11") = 24 And _
    Range("B18") = 24 And _

  3. #3
    RAP
    Guest

    Re: Nested If/And Function formula to VB code

    Earl,
    Thank you so much for the help. I chose the Do-Loop, because I will only
    have to change one variable if I add another "range of 7". I'm trying to
    use/learn as many different techniques in this project as I can. Do-Loop won
    the battle this time with me, but I now have a working model to examine.
    Many thanks,
    Randy

    "Earl Kiosterud" wrote:

    > RAP,
    >
    > If Range("B11") = 24 And _
    > Range("B18") = 24 And _
    > .
    > .
    > Range("B60") = 24 _
    > Then
    > --------------------------------------------------
    > Or if the number will change:
    >
    > Dim CmpNum
    >
    > CmpNum= 24
    >
    > If Range("B11") = CmpNum And _
    > Range("B18") = CmpNum And _
    > .
    > .
    > Range("B60") = CmpNum _
    > Then
    > -----------------------------------------------------------
    > Or
    >
    > Const CmpNum = 24
    >
    > If Range("B11") = CmpNumAnd _
    > Range("B18") = CmpNumAnd _
    > .
    > .
    > Range("B60") = CmpNum _
    > Then
    > --------------------------------------------
    > Since they're all in column B, and are 7 cells apart, you could loop through
    > them:
    >
    > Dim result As Boolean
    > Dim i As Integer
    > result = True
    >
    > For i = 11 To 60 Step 7
    > Cells(i, 2).Select
    > If Cells(i, 2) <> CmpNum Then
    > result = False
    > Exit For
    > End If
    > Next i
    > If result = True Then
    >
    > Be aware that in any of these macro solutions, if you move the cells
    > (including resulting from an insert or delete), these cell references will
    > not move with them. You have to use range names in your macro for that to
    > work.
    > --
    > Earl Kiosterud
    > www.smokeylake.com
    >
    > "RAP" <[email protected]> wrote in message
    > news:[email protected]...
    > >I have an inefficient, but working, nested if-and worksheet function
    > >formula
    > > that I need to put into a macro. I almost got "do-looped" to death today.
    > > Any help or direction would be most appreiciated. - Randy
    > >
    > >
    > > Range("H11").Select (Activecell)
    > > ActiveCell.Formula =
    > > "=IF(AND(B11=24,B18=24,B25=24,B32=24,B39=24,B46=24,B53=24,B60=24),TRUE,FALSE)"
    > >
    > > If ActiveCell = True Then
    > >
    > > Else:
    > >

    >
    >
    >


+ 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