Loop and Select Case Problem

drmingle

Board Regular
Joined
Oct 5, 2009
Messages
229
I have a worsheet labeled "test". In column A1 through A100 I have codes such as A1=00100, A2=0230, etc. I am looking to use the select case method and a loop to find the various corresponding descriptions that go with the code. So A1 = original code as entered and B1 = description found using the below select case.

Problem: I am not able to get the loop and select case to work together.

Any help would be appreciated...

Code:
Sub Search()
'
' Objective: to find code one by one and align code with corresponding parent ID
' Example: code 00102 = ABC, cod 00349 = DEF, code 00500 = "Go Look"
 
Dim rRange As Range
Dim rCell As Range
    Set rRange = Sheets("test").Range("A1", Range("A65536").End(xlUp))
 
    For Each rCell In rRange
Select Case rCell
Case 100 To 222
rCell.Offset(1, 1).Select = "ABC"
Case 300 To 352
rCell.Offset(1, 1).Select = "DEF"
Case Else
rCell.Offset(1, 1).Select = "Go Look"
End Select
 
    Next rCell
End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
It should be .Value not .Select

Code:
rCell.Offset(1, 1).Value = "ABC"
 
Upvote 0
Perfect solution...

Also, I changed it from (1,1) to (0,1) to get everything aligned.

You were lightning fast...

Thank you for making MrExcel forum a helpful place.:)
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top