Results 1 to 32 of 32

Select Case Statement

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Select Case Statement

    Hi all,

    I have tried my best but can't get the following code to do what I want it to do:

    Option Explicit
    Dim zName As String, prov As string
    
    Private Sub commandbutton1_click()
    Dim response As Integer
    zName = InputBox("Please enter the Z-file name", "Enter Z-File Name", "Z-file name")
    response = MsgBox("Is " & UCase(zName) & " the correct file name?", vbYesNo + vbQuestion, "Z-File Name")
    If response = vbYes Then
    Call SelectProvinceCase
    Application.Workbooks.Open ("http://sharepoint/sites/hbm/Audit/OSAM Z FILES/" & prov & "/" & zName & ".csv")
    If Left(zName, 5) = "Z4343" Or "Z4545" Then
    Call AlignData
    End If
    Call DeleteColumns
    Call SortColumns
    Call ColumnSort2
    Call Headings2
    Call FormatSheet
    End Sub
    
    Sub SelectProvinceCase()
    prov = Left(zName, 5)
    Select Case prov
        Case Z4141
            prov = "Nova Scotia Providers"
        Case Z4242
            prov = "Quebec Providers"
        Case Z4343
            prov = "NFLD Providers"
        Case Z4444
            prov = "NEW Brunswick Providers"
        Case Z4545
            prov = "PEI Providers"
        Case Z4646
            prov = "Ontario Providers"
        Case Z4747
            prov = "Saskatchewan Providers"
        Case Z4848
            prov = "Saskatchewan Providers"
        Case Z4949
            prov = "Alberta Providers"
        Case Z5050
            prov = "British Columbia Providers"
        Case Else
            MsgBox "Please verify the z-file name - the provider number appears to be incorrect."
        Exit Sub
    End Select
    End Sub
    The SelectProvinceCase is not working so I know it is not written correctly.

    If the first five characters of the file name is Z4949, for example, I want Alberta Providers to be inserted where prov is in

    Application.Workbooks.Open ("http://sharepoint/sites/hbm/Audit/OSAM Z FILES/" & prov & "/" & zName & ".csv")
    so that the code will open the file.

    Can someone fix the code for me, please.

    Thank you,
    Gos-C
    Last edited by Gos-C; 06-05-2008 at 02:11 PM.
    Using Excel 2010 & Windows 10
    "It is better to be prepared for an opportunity and not have one than to have an opportunity and not be prepared."

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Spellnumber
    By Williams in forum Excel - New Users/Basics
    Replies: 13
    Last Post: 02-16-2020, 03:34 AM
  2. Select Case Statement
    By Gos-C in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-13-2008, 09:34 AM
  3. "Translating" numbers into words
    By Portuga in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2008, 11:44 AM
  4. Spell number
    By nowfal in forum Excel General
    Replies: 4
    Last Post: 08-20-2007, 04:21 PM
  5. [SOLVED] Variable Command Statment w/ Select Case
    By mpeplow in forum Excel General
    Replies: 1
    Last Post: 04-06-2007, 05:49 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1