Simple Questions

  • Thread starter Thread starter James
  • Start date Start date
J

James

Is it possible to write a routine in certain programming language and
direct excell to run the routine and then place the result into a cell
in EXCEL?

Thanks

James
 
James,

Is the routine to be in the Excel workbook. If so, it is as simple as

'your code here to calculate a variable myResult
Range("A1").Value = myResult

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Actually I


I don't have any trouble calculating single variables,

A typical routine that I write would be a loop that given 10 numbers
in sequence, if the most recent value is >= 7 of the ten preceeding
numbers then the routine would return a value of 7 or if >= 4 of the
preceeding numbers would return a balueb of 4 and so on.

Right now what I have to do is save a column of numbers as a text
file, then run the text file though a qbasic routine and then paste
the results back into EXCEL. This works but it is time consuming.

I have never graduated out of qbasic because it has always been
adequete for the simple things I do with it.

James
 
You can use VBA in Excel to do this. In Excel, do Alt+F11 to get to the VBA
editor. In the Project window, make sure you workbook is selected (or
select it). then do Insert=>Module

paste in code like this:

Sub Updatecount()
If Selection.Columns.Count > 1 Then Exit Sub
icnt = 0
For i = 1 To Selection.Count - 1
If Selection(i) <= Selection( _
Selection.Count) Then _
icnt = icnt + 1
Next
Selection(Selection.Count, 2).Value = icnt
End Sub


Do Alt+F11 to go back to Excel.

Select 10 contiguous cells in a column with the column to the right blank.

do Tools=>Macro=>Macors and select Updatecount. Then hit run.

You should be able to do most things that you have done in qbasic, right in
Excel.
 
Back
Top