• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Problem with nested select case

Prem.Prakash

New Member
Hi,
I am trying to use the select case statement in a do while loop to select the appropriate value and populate other cell based on the value of active cell. While it works for all the values but does not work for 0. Given below is the code:
Sub select_case()

Range("K2").Select

Do While ActiveCell.Value <> Empty
Select Case ActiveCell.Value
Case 0: ActiveCell.Offset(0, 2).Value = "RFT"
Case 1: ActiveCell.Offset(0, 2).Value = "ON HOLD BED"
Case 2: ActiveCell.Offset(0, 2).Value = "Data Transferred"
End Select
ActiveCell.Offset(1, 0).Select
Loop

End Sub
When the active cell value is 1 or 2, it correctly populates On Hold BED or Data Transferred but with 0, nothing happens.

Please help what's the problem here.

Thanks in advance.
Cheers
Prem
 

Attachments

  • Problem with nested select case.xlsm
    15.3 KB · Views: 3
Hi:

Use the following code:

Code:
Sub select_case()

Range("K2").Select

Do While ActiveCell.Value <> vbNullString
    Select Case ActiveCell.Value
        Case 0: ActiveCell.Offset(0, 1).Value = "RFT"
        Case 1: ActiveCell.Offset(0, 1).Value = "ON HOLD BED"
        Case 2: ActiveCell.Offset(0, 1).Value = "Data Transferred"
    End Select
ActiveCell.Offset(1, 0).Select
Loop
   
End Sub

Thanks
 
Back
Top