ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with code - Help (https://www.excelbanter.com/excel-programming/405211-problem-code-help.html)

Les

Problem with code - Help
 
Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\Ge neral\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\Gene ral\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub

--
Les

joel

Problem with code - Help
 
You had a from in the old workbook that need to be copied into the new
workbook. If the form is a worksheet
1) open both the new and old workbook
2) right click the tab on the bottom of the old workbook form and select
copy. then select the new workbook

If the form is in VBA
1) Right click the form in the VBA Project window and select export. export
to a file
2) Import the file into the new workbook VBA Project window

"Les" wrote:

Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\Ge neral\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\Gene ral\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub

--
Les


Les

Problem with code - Help
 
Hi Joel, it is within the same workbook, just a new module ?
--
Les


"Joel" wrote:

You had a from in the old workbook that need to be copied into the new
workbook. If the form is a worksheet
1) open both the new and old workbook
2) right click the tab on the bottom of the old workbook form and select
copy. then select the new workbook

If the form is in VBA
1) Right click the form in the VBA Project window and select export. export
to a file
2) Import the file into the new workbook VBA Project window

"Les" wrote:

Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\Ge neral\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\Gene ral\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub

--
Les


joel

Problem with code - Help
 
How is frmSelection defined? I don't think the problem is with the new
module, just frmSelection is not defined in the new module.

"Les" wrote:

Hi Joel, it is within the same workbook, just a new module ?
--
Les


"Joel" wrote:

You had a from in the old workbook that need to be copied into the new
workbook. If the form is a worksheet
1) open both the new and old workbook
2) right click the tab on the bottom of the old workbook form and select
copy. then select the new workbook

If the form is in VBA
1) Right click the form in the VBA Project window and select export. export
to a file
2) Import the file into the new workbook VBA Project window

"Les" wrote:

Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\Ge neral\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\Gene ral\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub

--
Les


Les

Problem with code - Help
 
Hi Joel, the form is doing what i want it to, however if you see in my code
after the last if statement if all are true, it should branch to the Sub
GetLcsdate, but it goes straight to Problem: ??
--
Les


"Joel" wrote:

How is frmSelection defined? I don't think the problem is with the new
module, just frmSelection is not defined in the new module.

"Les" wrote:

Hi Joel, it is within the same workbook, just a new module ?
--
Les


"Joel" wrote:

You had a from in the old workbook that need to be copied into the new
workbook. If the form is a worksheet
1) open both the new and old workbook
2) right click the tab on the bottom of the old workbook form and select
copy. then select the new workbook

If the form is in VBA
1) Right click the form in the VBA Project window and select export. export
to a file
2) Import the file into the new workbook VBA Project window

"Les" wrote:

Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\Ge neral\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\Gene ral\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub

--
Les


joel

Problem with code - Help
 
You better signgle step through the old module and new module to see the
difference in the two modules.

Left click on first instruction in code. then press F8 to step through
code. See which item(s) is false in old code. Compare with new code.

I don't see any thing in the code you posted that is dependant on a NEW MODULE

"Les" wrote:

Hi Joel, the form is doing what i want it to, however if you see in my code
after the last if statement if all are true, it should branch to the Sub
GetLcsdate, but it goes straight to Problem: ??
--
Les


"Joel" wrote:

How is frmSelection defined? I don't think the problem is with the new
module, just frmSelection is not defined in the new module.

"Les" wrote:

Hi Joel, it is within the same workbook, just a new module ?
--
Les


"Joel" wrote:

You had a from in the old workbook that need to be copied into the new
workbook. If the form is a worksheet
1) open both the new and old workbook
2) right click the tab on the bottom of the old workbook form and select
copy. then select the new workbook

If the form is in VBA
1) Right click the form in the VBA Project window and select export. export
to a file
2) Import the file into the new workbook VBA Project window

"Les" wrote:

Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\Ge neral\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\Gene ral\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub

--
Les


Les

Problem with code - Help
 
That is the problem, if i step through with F8 it works but with F5 and
running it goes to "Problem:"

I am really puzzled....
--
Les


"Joel" wrote:

You better signgle step through the old module and new module to see the
difference in the two modules.

Left click on first instruction in code. then press F8 to step through
code. See which item(s) is false in old code. Compare with new code.

I don't see any thing in the code you posted that is dependant on a NEW MODULE

"Les" wrote:

Hi Joel, the form is doing what i want it to, however if you see in my code
after the last if statement if all are true, it should branch to the Sub
GetLcsdate, but it goes straight to Problem: ??
--
Les


"Joel" wrote:

How is frmSelection defined? I don't think the problem is with the new
module, just frmSelection is not defined in the new module.

"Les" wrote:

Hi Joel, it is within the same workbook, just a new module ?
--
Les


"Joel" wrote:

You had a from in the old workbook that need to be copied into the new
workbook. If the form is a worksheet
1) open both the new and old workbook
2) right click the tab on the bottom of the old workbook form and select
copy. then select the new workbook

If the form is in VBA
1) Right click the form in the VBA Project window and select export. export
to a file
2) Import the file into the new workbook VBA Project window

"Les" wrote:

Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\Ge neral\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\Gene ral\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub

--
Les


joel

Problem with code - Help
 
Put a break point on Problem using F9. Then add variabgbles to watch window
(right click on variable) like blnIhKtl to find out which is not set
corrrectly. I suspect you may have problems with your IfSheetExistsTestIH
macro.

"Les" wrote:

That is the problem, if i step through with F8 it works but with F5 and
running it goes to "Problem:"

I am really puzzled....
--
Les


"Joel" wrote:

You better signgle step through the old module and new module to see the
difference in the two modules.

Left click on first instruction in code. then press F8 to step through
code. See which item(s) is false in old code. Compare with new code.

I don't see any thing in the code you posted that is dependant on a NEW MODULE

"Les" wrote:

Hi Joel, the form is doing what i want it to, however if you see in my code
after the last if statement if all are true, it should branch to the Sub
GetLcsdate, but it goes straight to Problem: ??
--
Les


"Joel" wrote:

How is frmSelection defined? I don't think the problem is with the new
module, just frmSelection is not defined in the new module.

"Les" wrote:

Hi Joel, it is within the same workbook, just a new module ?
--
Les


"Joel" wrote:

You had a from in the old workbook that need to be copied into the new
workbook. If the form is a worksheet
1) open both the new and old workbook
2) right click the tab on the bottom of the old workbook form and select
copy. then select the new workbook

If the form is in VBA
1) Right click the form in the VBA Project window and select export. export
to a file
2) Import the file into the new workbook VBA Project window

"Les" wrote:

Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\Ge neral\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\Gene ral\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub

--
Les


Les

Problem with code - Help
 
Thanks, will try that...
--
Les


"Joel" wrote:

Put a break point on Problem using F9. Then add variabgbles to watch window
(right click on variable) like blnIhKtl to find out which is not set
corrrectly. I suspect you may have problems with your IfSheetExistsTestIH
macro.

"Les" wrote:

That is the problem, if i step through with F8 it works but with F5 and
running it goes to "Problem:"

I am really puzzled....
--
Les


"Joel" wrote:

You better signgle step through the old module and new module to see the
difference in the two modules.

Left click on first instruction in code. then press F8 to step through
code. See which item(s) is false in old code. Compare with new code.

I don't see any thing in the code you posted that is dependant on a NEW MODULE

"Les" wrote:

Hi Joel, the form is doing what i want it to, however if you see in my code
after the last if statement if all are true, it should branch to the Sub
GetLcsdate, but it goes straight to Problem: ??
--
Les


"Joel" wrote:

How is frmSelection defined? I don't think the problem is with the new
module, just frmSelection is not defined in the new module.

"Les" wrote:

Hi Joel, it is within the same workbook, just a new module ?
--
Les


"Joel" wrote:

You had a from in the old workbook that need to be copied into the new
workbook. If the form is a worksheet
1) open both the new and old workbook
2) right click the tab on the bottom of the old workbook form and select
copy. then select the new workbook

If the form is in VBA
1) Right click the form in the VBA Project window and select export. export
to a file
2) Import the file into the new workbook VBA Project window

"Les" wrote:

Hi all,

I have been using the code below with no problem and have just moved it to a
new module and now it wont work ??

Any suggestions welcome, i am not a programmer but a dabbler & just cannot
find the problem.

Sub ChkForFiles()
'
Dim sLCS As String, LCS As String, sIhKTL As String, ihKtl As String
Dim sKTL As String, KTL As String
Dim blnIhKtl As Boolean, blnKtl As Boolean, blnLCS As Boolean, ihSh As
Boolean
Dim ktlSh As Boolean


sLCS = "\\zapad01\sapinter\LCS\" & mylcs & ".xls"
blnLCS = Len(Dir(sLCS))

sIhKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTLih & ".xls"
blnIhKtl = Len(Dir(sIhKTL))

sKTL = "\\nv09002\tpdrive\Projects\General\50_Comparisons \KTL's\" &
myKTL & ".xls"
blnKtl = Len(Dir(sKTL))

If
IfSheetExistsTestIH("\\nv09002\tpdrive\Projects\Ge neral\50_Comparisons\KTL's\" & myKTLih & ".xls", "TOOL TRACKING") = True Then
ihSh = True
If
IfSheetExistsTest("\\nv09002\tpdrive\Projects\Gene ral\50_Comparisons\KTL's\"
& myKTL & ".xls", "TOOL TRACKING") = True Then
ktlSh = True
End If
End If

If blnLCS = True Then
If blnIhKtl = True Then
If ihSh = True Then
If blnKtl = True Then
If ktlSh = True Then
GetLcsdate**** Goes to Problem if all true ???
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If
Else
GoTo Problem
End If


Problem:


With frmSelection.Label1
.Caption = "ONE OR MORE FILES/SHEETS NOT AVAILABLE:" & vbCrLf &
vbCrLf & _
"LCS File Available : " & blnLCS & vbCrLf & _
"IH KTL File Available : " & blnIhKtl & vbCrLf & _
"Correct WorkSheet : " & ihSh & vbCrLf & _
"KTL File Available : " & blnKtl & vbCrLf & _
"Correct WorkSheet : " & ktlSh & vbCrLf & vbCrLf & _
"Click ""Reset"" to continue..."
.Font.Name = "Arial"
.Font.Size = 10
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 1, 52)
End With

End Sub

--
Les



All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com