Consulting

Results 1 to 10 of 10

Thread: Solved: Select Case

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Unhappy Solved: Select Case

    Im brain dead. How do you use the following correctly so if range B1 on sheet 1 = "Y", then put the value of sheet1 range A160 in sheet 2 range E6?

    [vba]Select Case Sheets("Sheet1").Range("B1")
    Case "Y"
    Sheets("Sheet2").Range("E6") = sheets("Sheet1").Range("A160")

    End Select[/vba]
    Peace of mind is found in some of the strangest places.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That is correct Austen, what makes you think it is not?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    You know your right Bob. Been up too long. Thanks for checking my sanity.
    Peace of mind is found in some of the strangest places.

  4. #4
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Well if I add another condition it doesnt populate with the "N" Sheet2 value stays populated with "Y":

    [vba]Select Case Sheets("Sheet1").Range("B1").Value
    Case "Y"
    Sheets("Sheet2").Range("E6") = Sheets("Sheet1").Range("A160")
    Case "N"
    Sheets("Sheet2").Range("E6") = Sheets("Sheet1").Range("A161")
    End Select[/vba]
    Peace of mind is found in some of the strangest places.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why are you picking up A160/A161, why not just B1 if you want the Y or N?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    If B1 is "Y" then I want the value in E160 to show on sheet2, if "N" then I want the value of A161 in sheet 2.
    Peace of mind is found in some of the strangest places.

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Which is exactly what that code does.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    I discovered that after i clicked out of B1. Told you I have been up too long.
    Peace of mind is found in some of the strangest places.

  9. #9
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by austenr
    Im brain dead....
    Hey Mister! No stealing my specialty!

  10. #10
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Peace of mind is found in some of the strangest places.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •