Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RAP RAP is offline
external usenet poster
 
Posts: 49
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 611
Default Nested If/And Function formula to VB code

RAP,

If Range("B11") = 24 And _
Range("B18") = 24 And _
  #3   Report Post  
Posted to microsoft.public.excel.programming
RAP RAP is offline
external usenet poster
 
Posts: 49
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested formula using WORKDAY function davisk Excel Worksheet Functions 5 October 19th 07 02:53 PM
A challenge: referencing cell contents in nested function formula Needs Assistance Excel Worksheet Functions 3 October 28th 06 02:17 AM
can you nested sum and round function within if function? anna Excel Worksheet Functions 4 May 27th 06 06:06 AM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM
Nested IF Function, Date Comparing, and NetworkDays Function carl Excel Worksheet Functions 2 December 29th 04 09:57 PM


All times are GMT +1. The time now is 03:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"