Solved

VBA Code

Posted on 2011-09-03
4
274 Views
Last Modified: 2012-05-12
Hello I have this code below, that is not working properly.  It my current set X37=0 and Y37=2, but it keeps putting the value of "P", when it should be "Y"  Any help would be greatly appreciated

If WS.Range("X37").Value >= 2 And WX.Range("Y37").Value >= 1 Then
    'Purple
    Range("B" & Cells(65536, "B").End(xlUp).Row + 1).Value = "P"
Else
    If WS.Range("X37") >= 1 Then
        'Red
        Range("B" & Cells(65536, "B").End(xlUp).Row + 1).Value = "R"
    Else
        If WS.Range("Y37") >= 1 Then
            'Yellow
            Range("B" & Cells(65536, "B").End(xlUp).Row + 1).Value = "Y"
        End If
    End If
End If
0
Comment
Question by:sandramac
  • 3
4 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 36479280
Looks like a typo in the first statement with WX.Range("Y37") instead of WS.Range("Y37")
0
 

Author Comment

by:sandramac
ID: 36479282
Thanks, the simplest things, I been studying so hard on it i overlook such a small thing
0
 
LVL 81

Expert Comment

by:byundt
ID: 36479285
sandramac,
Could you post your workbook? From your question, it doesn't seem possible that you would get a value of "P" so we will need to see the code in context with your layout.

Brad
0
 
LVL 81

Expert Comment

by:byundt
ID: 36479288
sandramac,
You can avoid typos like this if you use Option Explicit on every module sheet. You can set it up to be inserted automatically using the Tools...Options...Editor menu item (in the VBA Editor) and checking the box for "Require variable declaration"

Brad
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question