thomashp79
03-25-2015, 01:39 PM
Hi all :)
This is my first post so hope I don't ask in the wrong section.
I am trying to shorten the following code down so that I don't have to write the same line over and over but instead use arrays or something equivalent.
(This is only part of my code and different sections of it)
Dim FilePath1 As String
Dim FilePath2 As String
Dim FilePath3 As String
------------------------------------------------------------------------------------
Open FilePath1 For Input As #1
Open FilePath2 For Input As #2
Open FilePath3 For Input As #3
---------------------------------------------------------------------------------------
Do Until EOF(1)
Line Input #1, strFirstLine1
Loop
Do Until EOF(2)
Line Input #2, strFirstLine2
Loop
Do Until EOF(3)
Line Input #3, strFirstLine3
Loop
------------------------------------------------------------------------------
If IsNumeric(strFirstLine1) Then
Sheet1.Range("D2") = (strFirstLine1)
End If
Close #1
If IsNumeric(strFirstLine2) Then
Sheet1.Range("B2") = (strFirstLine2)
End If
Close #2
If IsNumeric(strFirstLine3) Then
Sheet1.Range("D3") = (strFirstLine3)
End If
Close #3
------------------------------------------------------------------------------
If Sheet1.Range("A13") < Sheet1.Range("B13") Then
Sheet1.Range("C13") = "TRUE"
Else
Sheet1.Range("C13") = "FALSE"
End If
If Sheet1.Range("A14") < Sheet1.Range("B14") Then
Sheet1.Range("C14") = "TRUE"
Else
Sheet1.Range("C14") = "FALSE"
End If
If Sheet1.Range("A15") < Sheet1.Range("B15") Then
Sheet1.Range("C15") = "TRUE"
Else
Sheet1.Range("C15") = "FALSE"
End If
This is my first post so hope I don't ask in the wrong section.
I am trying to shorten the following code down so that I don't have to write the same line over and over but instead use arrays or something equivalent.
(This is only part of my code and different sections of it)
Dim FilePath1 As String
Dim FilePath2 As String
Dim FilePath3 As String
------------------------------------------------------------------------------------
Open FilePath1 For Input As #1
Open FilePath2 For Input As #2
Open FilePath3 For Input As #3
---------------------------------------------------------------------------------------
Do Until EOF(1)
Line Input #1, strFirstLine1
Loop
Do Until EOF(2)
Line Input #2, strFirstLine2
Loop
Do Until EOF(3)
Line Input #3, strFirstLine3
Loop
------------------------------------------------------------------------------
If IsNumeric(strFirstLine1) Then
Sheet1.Range("D2") = (strFirstLine1)
End If
Close #1
If IsNumeric(strFirstLine2) Then
Sheet1.Range("B2") = (strFirstLine2)
End If
Close #2
If IsNumeric(strFirstLine3) Then
Sheet1.Range("D3") = (strFirstLine3)
End If
Close #3
------------------------------------------------------------------------------
If Sheet1.Range("A13") < Sheet1.Range("B13") Then
Sheet1.Range("C13") = "TRUE"
Else
Sheet1.Range("C13") = "FALSE"
End If
If Sheet1.Range("A14") < Sheet1.Range("B14") Then
Sheet1.Range("C14") = "TRUE"
Else
Sheet1.Range("C14") = "FALSE"
End If
If Sheet1.Range("A15") < Sheet1.Range("B15") Then
Sheet1.Range("C15") = "TRUE"
Else
Sheet1.Range("C15") = "FALSE"
End If