Re: If..Then statement

From: Don Guillett (donaldb_at_281.com)
Date: 11/16/04


Date: Tue, 16 Nov 2004 13:20:20 -0600

I would think you need an end if after each block . Better to use select
case.

-- 
Don Guillett
SalesAid Software
donaldb@281.com
"StephanieH" <StephanieH@discussions.microsoft.com> wrote in message
news:DE835457-E860-4770-861D-2A612DD2CE8B@microsoft.com...
> I seem to be having a problem with a simple If.. Then statement.
>
> I have the following:
>
> Private Sub OK_Click()
>
>
> If ListBox1.ListIndex = 0 Then
> ChDir "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
MIS\Chargeoff
> Trends"
>     Workbooks.Open Filename:= _
>         "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
> MIS\Chargeoff Trends\ADU Chargeoffs.xls"
>
>
> If ListBox1.ListIndex = 1 Then
> ChDir "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
MIS\Chargeoff
> Trends"
>     Workbooks.Open Filename:= _
>         "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
> MIS\Chargeoff Trends\Agency Chargeoffs.xls"
>
>
>
>
> If ListBox1.ListIndex = 2 Then
> ChDir "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
MIS\Chargeoff
> Trends"
>     Workbooks.Open Filename:= _
>         "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
> MIS\Chargeoff Trends\Attorney Chargeoffs.xls"
>
>
>
> If ListBox1.ListIndex = 3 Then
> ChDir "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
MIS\Chargeoff
> Trends"
>     Workbooks.Open Filename:= _
>         "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
> MIS\Chargeoff Trends\Deceased Chargeoffs.xls"
>
>
>
>
> If ListBox1.ListIndex = 4 Then
> ChDir "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
MIS\Chargeoff
> Trends"
>     Workbooks.Open Filename:= _
>         "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
> MIS\Chargeoff Trends\Internal Chargeoffs.xls"
>
>
>
>
> If ListBox1.ListIndex = 5 Then
> ChDir "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
MIS\Chargeoff
> Trends"
>     Workbooks.Open Filename:= _
>         "\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery
> MIS\Chargeoff Trends\Large Balance Chargeoffs.xls"
>
> Unload UserForm1
>
> End Sub
>
> I'm getting the message "Block If without End if".  I've tried adding "End
> if" between "Unload UserForm1" and End Sub, but that's not working.  It's
a
> multiselect ListBox so if I add End If between the ListIndexes it only
opens
> the last file selected.
>
> Help...


Relevant Pages

  • Re: If..Then statement
    ... >> Trends" ... Workbooks.Open Filename:= _ ...
    (microsoft.public.excel.misc)
  • Re: block of code doesnt get executed
    ... Check to see if chdir() succeeded: ... $filename has not been used until now, ... A carat in a regex means the beginning of a string. ... [snip rest of code] ...
    (comp.lang.perl.misc)
  • Re: Email Attachment Problem
    ... I created another filename string, so I can use it in the subject ... ChDir and set the default to the zipped files directory. ... >> Dim strDate As String, DefPath As String, strbody As String ...
    (microsoft.public.excel.programming)
  • Re: Prompt for filename in excel macro VBA
    ... I'm setting up a basic macro to copy data from one spreadsheet to the ... prompt to enter the filename? ... ' UpdateCurrentWeek Macro ...
    (microsoft.public.excel.programming)
  • If..Then statement
    ... Private Sub OK_Click ...
    (microsoft.public.excel.misc)