473,753 Members | 7,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assign letter to a number? where "for z = 1 - 4" I want 1 =N 2=W 3=E 4=S

3 New Member
Expand|Select|Wrap|Line Numbers
  1. Public col, nmb, x, y, z As Variant
  2. Public hw(17) As Variant
  3. Public buses(17, 200), sht, dt, nme, per, rnk As String
  4. '
  5. '
  6. '
  7. ' Function Makelist
  8. ' Updated by DEE 5/10/1999
  9. '
  10. Sub Makelist()
  11.     sht = ActiveSheet.Name
  12.     col = 1
  13.     msg = "Would you like to print individual Regions for " + Format(sht, "mmmm yyyy") + "?"
  14.     Style = vbYesNoCancel + vbQuestion + vbDefaultButton1
  15.     Title = "What is your bidding, master?"
  16.     response = MsgBox(msg, Style, Title)
  17.     If response = vbCancel Then End
  18.     If response = vbYes Then
  19.         dist = InputBox(Title:="Single Region Printing", prompt:="Which Region?", default:="1")
  20.     If dist = "" Or Val(dist) > 4 Then End
  21.         z = Val(dist)
  22.         all = False
  23.     Else
  24.         all = True
  25.     End If
  26.  
  27.     whosename
  28.  
  29.     Sheets(Format(sht, "mmmm yyyy")).Select
  30.     If Not all Then
  31.         z = Val(dist)
  32.         Gather
  33.     ElseIf all Then
  34.         For z = 1 To 4
  35.             Gather
  36.         Next z
  37.     End If
  38. '
  39. '   Clear Details
Dec 17 '09 #1
8 1747
!NoItAll
297 Contributor
Expand|Select|Wrap|Line Numbers
  1. Dim NumberLetters(4) as String = {"", "N", "W", "E", "S"}
  2. Region = InputBox()
  3. Return NumberLetters(Cint(Region))
You'll need to do some error checking of course...
Dec 17 '09 #2
tlhintoq
3,525 Recognized Expert Specialist
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Dec 17 '09 #3
tlhintoq
3,525 Recognized Expert Specialist
Mate, it would really help if you could describe your need/question.
The little bit that fits in the title doesn't give us the big picture of what you are trying to accomplish
Dec 17 '09 #4
Twoshots64
3 New Member
My apologies, but I am not literate in VBA code etc. I have "inherited" an Excel program written some years ago that designs a "roster" and gather information from another spreadsheet and then produces a report from that roster.

Now they have changed the way the "label" the locations from, for example
1MW to NMW or 2AN to WAN. So now I need to understand how to change the numerical reference to an alpha reference and still produce the same reports, hopefully without resorting having to have someone re-write the whole thing.

How / where would I insert the response from !NoItAll?

Into this.

Mick's Stuff
' Macro Updated on 5/10/1999 by DEE
'
'
'
'
'Declarations

Expand|Select|Wrap|Line Numbers
  1. Public col, nmb, x, y, z As Variant
  2. Public hw(17) As Variant
  3. Public buses(17, 200), sht, dt, nme, per, rnk As String
  4. '
  5. '
  6. '
  7. ' Function Makelist
  8. ' Updated by DEE 5/10/1999
  9. '
  10. Sub Makelist()
  11.     sht = ActiveSheet.Name
  12.     col = 1
  13.     msg = "Would you like to print individual Regions for " + Format(sht, "mmmm yyyy") + "?"
  14.     Style = vbYesNoCancel + vbQuestion + vbDefaultButton1
  15.     Title = "What is your bidding, master?"
  16.     response = MsgBox(msg, Style, Title)
  17.     If response = vbCancel Then End
  18.     If response = vbYes Then
  19.         dist = InputBox(Title:="Single Region Printing", prompt:="Which Region?", default:="1")
  20.     If dist = "" Or Val(dist) > 4 Then End
  21.         z = Val(dist)
  22.         all = False
  23.     Else
  24.         all = True
  25.     End If
  26.  
  27.     whosename
  28.  
  29.     Sheets(Format(sht, "mmmm yyyy")).Select
  30.     If Not all Then
  31.         z = Val(dist)
  32.         Gather
  33.     ElseIf all Then
  34.         For z = 1 To 4
  35.             Gather
  36.         Next z
  37.     End If
Dec 17 '09 #5
Twoshots64
3 New Member
I'm happy to forward the whole file if someone can point me in the right direction.
Dec 17 '09 #6
tlhintoq
3,525 Recognized Expert Specialist
1MW to NMW or 2AN to WAN.
So the codes are already 1MW, 2AN etc.?
So you aren't just inserting a letter, but you need to actually read the existing code and change it based on the first letter of the code.
Is that right?
Dec 17 '09 #7
tlhintoq
3,525 Recognized Expert Specialist
1MW to NMW or 2AN to WAN.
So the codes are already 1MW, 2AN etc.?
So you aren't just inserting a letter, but you need to actually read the existing code and change it based on the first letter of the code.
Is that right?
Dec 17 '09 #8
tlhintoq
3,525 Recognized Expert Specialist
How / where would I insert the response from !NoItAll?
!NoItAll is suggesting that you create an array of letters that corresponds to your numbering
Expand|Select|Wrap|Line Numbers
  1. Dim NumberLetters(4) as String = {"", "N", "W", "E", "S"}
Element 1 is "N"
Element 2 is "W" and so on

This way you can match (or rebuild) your code "2an" to "Wan" by just taking the first character of the code, convert it to number and grab that element of the array.

"2" as a string becomes the int of 2.
NumberLetters[2] is "W"
Dec 17 '09 #9

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

Similar topics

4
11730
by: PhilC | last post by:
Hi Folks, If I have an array holding a pair of numbers, and that pairing is unique, is there a way that I can find the array index number for that pair? Thanks, PhilC
1
1301
by: taras | last post by:
IE 6.0 sockets number (TCP/IP channels number) for the same Site ??? I've discovered the restriction: IE 6.0 has 2 sockets only to the same Server (ASP.NET Site). Where can I find any kind of information about this limitation? P.S. IE 6.0 from Windows 2003 Server has the same limitation, but if the sockets number is increased to 3, then IE stuck (with Done status) till Refresh.
2
2301
by: mikeybe | last post by:
Anyone know how to return the disk number (i.e. the number you see when you launch windows disk manager and see your drives numbered disk 0, disk 1, etc.)? I'm not talking about the volume serial number or drive serial number. For example, I want to programatically determine what disk number the c drive is using vb.net and windows 2000. Thanks, Mike Beccaria
12
3079
by: tojigneshshah | last post by:
Hi, I have a situation where i have multiple batch and the each batch are sequence numbers. For each batch, the number should start with 1. For example: Col.no1 Col.no2 ------ ------- batch1 1 batch1 2
3
2859
by: petermichaux | last post by:
Hi, Is there an internally assigned number for each JavaScript object that I can read? If so how would I do that? Thanks, Peter
2
1920
by: rhepsi | last post by:
Hii all, I have a project where before i upload the data from 1st database to 2nd database, im truncating the 2nd database and then trying to upload... In this process, wat i found was that: My records in the database are something like: `tbl_workers` (`wo_worker_id_pk` bigint(11) unsigned NOT NULL auto_increment, `wo_worker_code` varchar(6) NOT NULL default '', `wo_worker_catagory` varchar(50) default NULL,
1
1523
by: Visame | last post by:
ofstream out1, out2; out1 = out2; // error: cannot assign stream objects // print function: parameter is copied ofstream print(ofstream); out2 = print(out2); // error: cannot copy stream objects Why there is NO Copy or Assign for IO Objects? Can anyone tell me the reason? Thanks!
2
12678
by: sheperson | last post by:
Hi, I have been working for several months on a sofware and now it is finished. I have a problem now and it is this: Because I live in a country which there is no copyright law in it (Iran!!!!). As soon as I give the software to some customers, the software will be copied illegally and I don't want this happen. Now I wonder if anyone could help me on how to create a lock or a serial number for the software. I want my software to...
8
1469
chandru8
by: chandru8 | last post by:
hi every body i need a logic , that for a particular code i need to genrate a serial number for a day should be one for the next day it should be increment to 2 like this can any one help me in this Please.., its urgent thanks a lot
8
23353
by: davidson1 | last post by:
Hai friends.... In C for 97=A character , 65=a charcter....can u tell what is the number for "space" character... Davidson
0
8896
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
9653
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...
0
9451
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9421
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,...
0
9333
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6869
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
4771
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3395
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

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.