- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am attempting to write a program that will take a set of values from Excel and have the math done in Fortran, using VBA as the intermediate. In an attempt to figure this out, I wrote a small VBA program that will take the values of cells and then perform operations, outputing to a second set of cells. The VBA code is:
Private Sub CommandButton1_Click()
Dim i As Integer, imax As Integer, imax1 As Integer
Dim x As Single, y As Single
imax = Sheet1.Cells(1, 1) ' Number of first type of operation to perform
imax2 = Sheet1.Cells(1, 2)
Private Sub CommandButton1_Click()
Dim i As Integer, imax As Integer, imax1 As Integer
Dim x As Single, y As Single
imax = Sheet1.Cells(1, 1) ' Number of first type of operation to perform
imax2 = Sheet1.Cells(1, 2)
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Whoops, I'm not sure what happened. Must've accidentally tabbed to the submit message. If I can try this again:
I am attempting to write a program that will take a set of values from Excel and have the math done in Fortran, using VBA as the intermediate. In an attempt to figure this out, I wrote a small VBA program that will take the values of cells and then perform operations, outputing to a second set of cells. The current VBA code, which does everything needed at the moment, is:
Private Sub CommandButton1_Click()
'Square a real number
Dim i As Integer, imax As Integer, imax1 As Integer
Dim x As Single, y As Single
imax = Sheet1.Cells(1, 1) 'Number of first type of operation to be performed
imax2 = Sheet1.Cells(1, 2) 'Number of second type of operation to be peformed
For i = 1 To imax
x = Sheet1.Cells(2, i)
y = x ^ 2
Sheet1.Cells(3, i) = y
Next i
Call subx(imax, imax2)
End Sub
Private Sub subx(imax, imax2)
'Convert to integer, then square as an integer
Dim x As Integer, y As Integer
For i = imax + 1 To imax2
x = Int(Sheet1.Cells(2, i))
y = x ^ 2
Sheet1.Cells(3, i) = y
Next i
End Sub
I figure that what I need to do is to create a Fortran DLL with both subroutines included and then have the VBA call the Fortran subroutines and then put the numbers into Excel. However, I'm getting stuck on how to translate the Sheet1.Cells code into what I need for a Do loop. Is there a good way to do this?
I am attempting to write a program that will take a set of values from Excel and have the math done in Fortran, using VBA as the intermediate. In an attempt to figure this out, I wrote a small VBA program that will take the values of cells and then perform operations, outputing to a second set of cells. The current VBA code, which does everything needed at the moment, is:
Private Sub CommandButton1_Click()
'Square a real number
Dim i As Integer, imax As Integer, imax1 As Integer
Dim x As Single, y As Single
imax = Sheet1.Cells(1, 1) 'Number of first type of operation to be performed
imax2 = Sheet1.Cells(1, 2) 'Number of second type of operation to be peformed
For i = 1 To imax
x = Sheet1.Cells(2, i)
y = x ^ 2
Sheet1.Cells(3, i) = y
Next i
Call subx(imax, imax2)
End Sub
Private Sub subx(imax, imax2)
'Convert to integer, then square as an integer
Dim x As Integer, y As Integer
For i = imax + 1 To imax2
x = Int(Sheet1.Cells(2, i))
y = x ^ 2
Sheet1.Cells(3, i) = y
Next i
End Sub
I figure that what I need to do is to create a Fortran DLL with both subroutines included and then have the VBA call the Fortran subroutines and then put the numbers into Excel. However, I'm getting stuck on how to translate the Sheet1.Cells code into what I need for a Do loop. Is there a good way to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I went through this. You could try this link http://softwareforums.intel.com/ids/board/message?board.id=5&message.id=4723&highlight=excel#M4723

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page