#1   Report Post  
Paige
 
Posts: n/a
Default IF help


Hello, I am trying to do some IF statements within a larger macro.
What I want to do is delete certain sections of a worksheet depending
on whether they have quantities in them or not. I got an IF statement
to work, but it carried what it needed to do if it was true whether it
was true or false. Right now I have it set up to just change the
background color until I know for sure it works because it helps me
keep track of what is working & not working while I am building the
macros. Below is an example of the IF statments that I can't get to
work the way I want. This is my first attempt at them so they may be
completely wrong.

If R2 = 0 Then
Range("A288:A334").Select
Selection.Interior.ColorIndex = 4
End If

If Q2 = 0 Then
Range("A240:A287").Select
Selection.Interior.ColorIndex = 14
End If

If P2 = 0 Then
Range("A192:A239").Select
Selection.Interior.ColorIndex = 39
End If

Thanks for any help!


--
Paige
------------------------------------------------------------------------
Paige's Profile: http://www.excelforum.com/member.php...o&userid=23096
View this thread: http://www.excelforum.com/showthread...hreadid=386913

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Should it be?

If Range("R2").Value = 0 Then
Range("A288:A334").Interior.ColorIndex = 4
End If

If Range("Q2").Value = 0 Then
Range("A240:A287")..Interior.ColorIndex = 14
End If

If Range("P2").Value = 0 Then
Range("A192:A239")..Interior.ColorIndex = 39
End If


--
HTH

Bob Phillips

"Paige" wrote in
message ...

Hello, I am trying to do some IF statements within a larger macro.
What I want to do is delete certain sections of a worksheet depending
on whether they have quantities in them or not. I got an IF statement
to work, but it carried what it needed to do if it was true whether it
was true or false. Right now I have it set up to just change the
background color until I know for sure it works because it helps me
keep track of what is working & not working while I am building the
macros. Below is an example of the IF statments that I can't get to
work the way I want. This is my first attempt at them so they may be
completely wrong.

If R2 = 0 Then
Range("A288:A334").Select
Selection.Interior.ColorIndex = 4
End If

If Q2 = 0 Then
Range("A240:A287").Select
Selection.Interior.ColorIndex = 14
End If

If P2 = 0 Then
Range("A192:A239").Select
Selection.Interior.ColorIndex = 39
End If

Thanks for any help!


--
Paige
------------------------------------------------------------------------
Paige's Profile:

http://www.excelforum.com/member.php...o&userid=23096
View this thread: http://www.excelforum.com/showthread...hreadid=386913



  #3   Report Post  
Paige
 
Posts: n/a
Default


THANK YOU!!!! It worked perfectly. Now I can quit pulling my hair
out..


--
Paige
------------------------------------------------------------------------
Paige's Profile: http://www.excelforum.com/member.php...o&userid=23096
View this thread: http://www.excelforum.com/showthread...hreadid=386913

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



All times are GMT +1. The time now is 05:34 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"