display a file in excel by using vba

Joined
Mar 12, 2012
Messages
2
Reaction score
0
hi, i need to display the values in the txt file into excel, the values are look like matrix.
How can i do it? This is what I got so far.

Code:
Dim n As Integer, i As Integer, j As Integer, solCost As Integer
    Dim inputFileName As String, groupSize As Integer
    
    'Ask the user for the input file name. The data in the input file is assumed to be in the right format
    inputFileName = InputBox("Enter Problem Filename (include .txt extension)")
    inputFileName = ActiveWorkbook.Path & "\" & inputFileName
    Open inputFileName For Input As #1
        
    'Now read in the variable n at the top of the file which is the size of the matrix
    Input #1, n
    
    'Now construct the (n x n) matrix that will hold the problem and read in the problem from the input file
    ReDim ProbMatrix(1 To n, 1 To n) As Integer
    For i = 1 To n
        For j = 1 To n
            Input #1, ProbMatrix(i, j)
        Next j
    Next i
    'Having read the problem we close the input file
    Close #1
but how can I display the value in excel??
Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top