473,657 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select Case Confusion

3 New Member
The following is my code - I'm new to VB - not to Excel - just VB and need some support/guidance/direction (please)

I have a spreadsheet and in column "X" titled COS I need to put an integer that corresponds with a string in column "Y" titled Dialing Options...

When I select, for example the number 17 (in column X) I want to populate the adjacent cell in column "Y" to read "Internal" or something along those lines...as an example...

I can do this without error as long as I only have on parameter for X and for Y - but I want to do the range of COS - and I'm not sure how to Dim it out to make it work - the range that is currently filled is X2:X142

Any help would be greatly appreciated...

Expand|Select|Wrap|Line Numbers
  1. Sub SelectCase_COS()
  2.  
  3. 'Select Case for Class of Service'
  4. 'Created by Jae Robinson 02/19/2007'
  5.  
  6.  
  7. Select Case Range("COS").Value
  8.  
  9.     Case 1 To 8
  10.         Range("Dialing_Options").Value = "Internal Only"
  11.     Case 9 To 12
  12.         Range("Dialing_Options").Value = "Internal & Local"
  13.     Case 13 To 40
  14.         Range("Dialing_Options").Value = "In/Loc/LD"
  15.     Case 41 To 50
  16.         Range("Dialing_Options").Value = "In/Loc/LD/Int"
  17.     Case 51 To 63
  18.         Range("Dialing_Options").Value = "No Restrictions"
  19.     Case 63
  20.         Range("Dialing_Options").Value = "Ability to Direct Select"
  21.     Case Else
  22.         Range("Dialing_Options").Value = ""
  23.  
  24. End Select
  25.  
  26. End Sub
Feb 19 '07 #1
2 1423
JP2R
3 New Member
Here it is as it is working without error...

Expand|Select|Wrap|Line Numbers
  1. Sub SelectCase_COS()
  2.  
  3. 'Select Case for Class of Service'
  4. 'Created by Jae Robinson 02/19/2007'
  5.  
  6.  
  7. Select Case Range("X2").Value
  8.  
  9.     Case 1 To 8
  10.         Range("Y2").Value = "Internal Only"
  11.     Case 9 To 12
  12.         Range("Y2").Value = "Internal & Local"
  13.     Case 13 To 40
  14.         Range("Y2").Value = "In/Loc/LD"
  15.     Case 41 To 50
  16.         Range("Y2").Value = "In/Loc/LD/Int"
  17.     Case 51 To 63
  18.         Range("Y2").Value = "No Restrictions"
  19.     Case 63
  20.         Range("Y2").Value = "Ability to Direct Select"
  21.     Case Else
  22.         Range("Y2").Value = ""
  23.  
  24. End Select
  25.  
  26. End Sub
Feb 19 '07 #2
Killer42
8,435 Recognized Expert Expert
I don't have the syntax handy at the moment, but I believe you need to use something like a For Each loop to run through the cells in "COS", and then you can probably use Offset to jump one place to the right, or to the corresponding position in another list, or whatever.
Feb 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

17
14626
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to allow entry to one or the other or Both at the same time. Now I tried to use an If ElseIf but it got too hard to track, so now I am using a SELECT CASE Statement.
9
3624
by: Kevin | last post by:
Hi, I am getting a syntax error Microsoft VBScript compilation error '800a03ea' Syntax error On the code below. The error references the "End Select" line Can anyone help me with what I am doing wrong? Thanks
10
2161
by: MLH | last post by:
Suppose the following... Dim A as Date A=#7/24/2005# I wish to compare value of A against 2 other values: 1) 8/1/2005 2) 9/1/2005 Which is better and why... First:
7
9327
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
3
3765
by: Rob Meade | last post by:
Ok - I *think* this is only different in .net 2.0 - as I've not had any problems in the past, but then maybe I've not tried it... I have a value being read from an xml file where the value maybe a word or a number, ie... Low or 1 Medium or 2 High or 3
8
4717
by: | last post by:
Hello, This is gonna sound real daft, but how do I test a Select Case statement for variants of a theme? Here's a snippet of my code... Select Case sUsr Case "Guest", "TsInternetUser", "krbtgt", "quality7" ' don't show
16
19039
by: ME | last post by:
In C# the following code generates a compiler error ("A constant value is expected"): public void Test(string value) { switch (value) { case SimpleEnum.One.ToString(): MessageBox.Show("Test 1"); break;
5
10115
by: PJ6 | last post by:
Select Case o.GetType Case = GetType(SomeRandomTypeName) '... End Select Why doesn't this work? Can I make it work or am I stuck with ElseIf for a long list? Paul
1
21666
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case "01" : dWarrExpDateMonth="Jan" : dRetailDateMonth="Jan" case "02" : dWarrExpDateMonth="Feb" : dRetailDateMonth="Feb" End Select
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.