View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Simple Questions

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.

--
Regards,
Tom Ogilvy

James wrote in message
...
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

"Bob Phillips" wrote in
:

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