[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

VBA Code

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
sandramac
Asked:
sandramac
  • 3
1 Solution
 
byundtCommented:
Looks like a typo in the first statement with WX.Range("Y37") instead of WS.Range("Y37")
0
 
sandramacAuthor Commented:
Thanks, the simplest things, I been studying so hard on it i overlook such a small thing
0
 
byundtCommented:
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
 
byundtCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now