Solved

VBA Code

Posted on 2011-09-03
4
246 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 80

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 80

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 80

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now