Built a formula or macro from Markov rules ?

serge

Well-known Member
Joined
Oct 8, 2008
Messages
1,413
Office Version
  1. 2007
Platform
  1. Windows
I wanted to ask if it would be possible to create a formula or macro with Markov rules in this website having the data in excel from A1:A490 ?

Thank you.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
VBA Code:
Sub Markov_macro()
'
' Markov_macro Macro
' Macro that transforms data into what can be used for Markov Chain
'for gsn casino
' Keyboard Shortcut: Ctrl+Shift+M
'
'declarations
Dim start_row As Integer
Dim end_row As Integer
Dim i As Integer
Dim column_to_fill As Integer
Dim column_to_check As Integer

'initializations
end_row = 130
start_row = 365
column_to_fill = 12
column_to_check = 11
'Fills the rows
For i = start_row To end_row
        If Worksheets("Table").Cells(i, column_to_check).Value >= 0 Then
        Worksheets("Table").Cells(i, column_to_fill).Value = 1
        Else
        Worksheets("Table").Cells(i, column_to_fill).Value = 0
        End If
        
Next i
        

End Sub
 
Upvote 0
Hi nemmi69,
Thank you for taking the time to do this task, I really appreciate it.
But I'm not an Excel savvy guy, could you please explain very quick how to use this code, Thank you.
 
Upvote 0
So
Dim start_row As Integer
Dim end_row As Integer
are the starting row and end row it will cover

Dim column_to_check As Integer
is the column it will go down

Dim column_to_fill As Integer
is which column to write to

change these as appropriate
 
Upvote 0
That is still Chinese for me, I will write my data in column A1 to hundred or thousands row, how do I incorporate the code in my excel file ?
Thank you.
 
Upvote 0
You will need to insert a module and copy this to the module

1659118628667.png


1) Open the VBA editor. The fastest way to do this would be to press Alt + F11 on the keyboard.
2) Right-click on the Excel file VBA project name - this will be the name of the Excel workbook (or any other item below, for example the “Microsoft Excel Objects” folder icon as in the screenshot).
3) Go to “Insert” and click on “Module”.

Now, when the right side goes white a module will be open. Copy all the code here.

1659119050373.png


Make sure that your cursor is located within your pasted code. Then, click on the green Start button to run the macro. Alternatively, press F5 on the keyboard.
 
Upvote 0
Additionally, there are a lot of tutorials and videos out there that can be found with Google searches which will show you where & how to insert VBA code and how to run it.
Here is one, but you can find many more: How to Add Macro Code to Excel Workbook
 
Upvote 0
I follow your instructions but when I run the code nothing happen I must do something wrong ???
My data are in A1:A496 where should the return be ?

Capture22.PNG


Up to 496 will the return of the code calculations will be in A497 ?
 
Upvote 0
Hi nemmi69,

Thank you for helping me, I thought that the formula in that website will calculate the string of data and return only 1 answer, so this is not what I was expected.
I'm looking for a program that will scan the history data and return the most probable answer.

I really appreciate your help, Thank you.
 
Upvote 0

Forum statistics

Threads
1,215,530
Messages
6,125,353
Members
449,220
Latest member
Edwin_SVRZ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top