excel vba correct declaring ????????

Please post any questions regarding the program here.

Moderator: 2020vision

excel vba correct declaring ????????

Postby alrodopial » Sun Jun 14, 2015 8:16 pm

Hi,
I have five markets linked to five sheets
I'm trying to place the data of these five ranges (range A1:P?? in every sheet) into a variable that has at least 5 "places"
How is called this variable that contains ranges? collection? object?
a one dimension variable: "MyTable1" declared "Public MyTable1(1 To 50, 1 To 1) As Object"
If I "Set MyTable1(1, 1) = Target" inside the worksheet_change event (in the example for the first tab)
I get it right but the data changes whenever the target is updated even if the code has not reached the line of code where I "Set MyTable1(1, 1) = Target"
This way I can not use it to compare it with the new data (new target) as they become the same
code below:
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
   
    If Target.Columns.Count = 16 Then
        Set ODDSrng = Target
        NoRows = ODDSrng.Rows.Count
        NoRUNNERS = NoRows - 4
       
        '
        '
        ' call macros here
        '
        '
       
        Set MyTable1(1, 1) = Target
       
        'Call assignDataToTable1
    End If
       
End Sub


I tried to copy the data I want (target) into new TEMP range and then set this range into MyTable(1,1) but I get error "object required" at row " Set MyTable1(1, 1) = TEMPrng" ( TEMPrng highlighted)
It should be easy to fix as it seems to be correct declaring or correct variables used problem
code below:
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
   
    If Target.Columns.Count = 16 Then
        Set ODDSrng = Target
        NoRows = ODDSrng.Rows.Count
        NoRUNNERS = NoRows - 4
       
        '
        '
        ' call macros here
        '
        '
       
        'Set MyTable1(1, 1) = Target
       
        Call assignDataToTable1
    End If
       
End Sub

Code: Select all
Public ODDSrng As Range
Public MyTable1(1 To 50, 1 To 1) As Object
Public NoRUNNERS As Integer
Public NoRows As Integer

Sub assignDataToTable1()
    Dim TEMPrng() As Range
    'Dim TEMPrng(1 To 50, 1 To 16) As Variant
    For x = 1 To NoRows
        For y = 1 To 16
            ReDim TEMPrng(x, y)
            TEMPrng(x, y) = ODDSrng(x, y)
        Next y
    Next x
   
    Set MyTable1(1, 1) = TEMPrng
   
End Sub
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Re: excel vba correct declaring ????????

Postby alrodopial » Mon Jun 15, 2015 1:17 pm

The below code seems to be working but I cant test it further for the moment
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
   
    If Target.Columns.Count = 16 Then
        Set ODDSrng = Target
        NoRows = ODDSrng.Rows.Count
        NoRUNNERS = NoRows - 4
       
        '
        '
        ' call macros here
        '
        '
       
        Call assignDataToTable1
    End If
       
End Sub


Code: Select all
Public ODDSrng As Range
Public MyTable1(50) As Variant
Public NoRUNNERS As Integer
Public NoRows As Integer

Sub assignDataToTable1()
       
    MyTable1(1) = ODDSrng
       
End Sub
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Re: excel vba correct declaring ????????

Postby rourkem » Wed Jun 24, 2015 8:02 pm

Hi buddy, how did testing here went out for you?
Windows 8 | Framework 2.0 Image
User avatar
rourkem
 
Posts: 166
Joined: Tue Oct 28, 2014 3:20 pm

Re: excel vba correct declaring ????????

Postby alrodopial » Sun Jun 28, 2015 10:15 am

something like the below works fine ( and not the one above)

Code: Select all
Public ODDSrngSTORED_TABLE(50) As Variant

Sub assignDataToTable1()
   
    Dim TEMParray(1 To 50, 1 To 16)
    For x = 1 To NoRows
        For y = 1 To 16
            TEMParray(x, y) = ODDSrng_BF(x, y)
        Next y
    Next x
    ODDSrngSTORED_TABLE(1) = TEMParray
       
End Sub
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Re: excel vba correct declaring ????????

Postby alrodopial » Sun Jun 28, 2015 10:19 am

and then you can use it like:

Traded Amounts = ODDSrngSTORED_TABLE(1)(3,2)
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm


Return to Help

Who is online

Users browsing this forum: Google [Bot] and 45 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.