+ Reply to Thread
Results 1 to 9 of 9

Thread: VBA to automatically enter values from another cell

  1. #1
    Forum Contributor
    Join Date
    06-28-2009
    Location
    newcastle, uk
    MS-Off Ver
    Excel 2010
    Posts
    120

    VBA to automatically enter values from another cell

    Hi all

    Firstly I want to thank everyone so far that has helped me out with the many questions I have put to you on here. It has not only helped a great deal, but it has really increased my knowledge and find myself being able to carry out formulas etc on my own now.

    On this occasion though I have a VBA I would like which I would struggle to put together myself. It is to do with my virtual horse racing I have had help with in the past. This time I am wanting to automatically add my nomination fees for each race I enter in. I have tried to explain the best I can in my attachment what is needed and I am hoping it can be achieved.

    Thanks to anyone who helps in advance.

    Gemma
    Last edited by batjl9; 07-06-2011 at 10:23 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: VBA to automatically enter values from another cell

    Maybe i am confused but why don't you just use a formula?

    So using your attached worksheet, Sheet 1 Cell X14 would have this put in it.
    =$K$2
    You would then fill down to X17. Do this for each one. Should only take a minute.

  3. #3
    Forum Contributor
    Join Date
    06-28-2009
    Location
    newcastle, uk
    MS-Off Ver
    Excel 2010
    Posts
    120

    Re: VBA to automatically enter values from another cell

    Quote Originally Posted by stnkynts View Post
    Maybe i am confused but why don't you just use a formula?

    So using your attached worksheet, Sheet 1 Cell X14 would have this put in it.
    =$K$2
    You would then fill down to X17. Do this for each one. Should only take a minute.
    Its just that I attached a small example. In reality this worksheet is going to have hundreds and hundreds of these races day and would be too much work going through them each day.Sorry i should have mentioned this was just a sample of the actual sheet I use.

    Thanks
    Gemma

  4. #4
    Forum Contributor
    Join Date
    06-28-2009
    Location
    newcastle, uk
    MS-Off Ver
    Excel 2010
    Posts
    120

    Re: VBA to automatically enter values from another cell

    Just to add I do have a similar sheet that looks at each set of races and automatically enters the jockey rankings from 1 to 34. I would imagine it would be using this type of code but changing it around.

    Sub RankGroups()
    Dim RNGs As Range
    Dim Grp As Long
    Dim First As String

    Set RNGs = Range("y:y").SpecialCells(xlCellTypeFormulas, xlNumbers)

    For Grp = 1 To RNGs.Areas.Count
    With RNGs.Areas(Grp)
    First = Replace(.Cells(1).Address, "$", "")
    .Offset(0, 1).Formula = "=RANK(" & First & "," & .Address & ",1)"
    End With
    Next Grp

    End Sub

  5. #5
    Valued Forum Contributor
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: VBA to automatically enter values from another cell

    Try this:

    Sub PopulateEntryFee()
    Dim myRange As Range
    Dim iGroup As Long
    
    Set myRange = ActiveSheet.Range("w:w").SpecialCells(xlCellTypeConstants, xlNumbers)
    
    For iGroup = 1 To myRange.Areas.Count
        With myRange.Areas(iGroup)
            .Offset(0, 1).Value = .Offset(-12, -12).Value
            .Offset(0, 1).FillDown
        End With
    Next iGroup
    
    End Sub

  6. #6
    Forum Contributor
    Join Date
    06-28-2009
    Location
    newcastle, uk
    MS-Off Ver
    Excel 2010
    Posts
    120

    Re: VBA to automatically enter values from another cell

    This is exactly what I was looking for, thank you very much!

    Gemma

  7. #7
    Valued Forum Contributor
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2003
    Posts
    2,488

    Re: VBA to automatically enter values from another cell

    option without specialcells, run code "test"
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    06-28-2009
    Location
    newcastle, uk
    MS-Off Ver
    Excel 2010
    Posts
    120

    Re: VBA to automatically enter values from another cell

    Thanks Watersev, this also works and it is great to see different styles when setting vba's up.

    I do actually have a similar question to the one solved, but never posted originally as I wasn't sure it was possible for the previous vba to be set up. It is similar to the one above, except for it is looking for the stakes returns of each race and only allocates a value to the first 4 horses in each race. I have attached an updated sheet if anyone has time to look at it.

    Thanks again to all who have viewed and commented. My hope is that through learning here I will eventually be able to answer some questions myself rather than be the one asking them.

    Gemma
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: VBA to automatically enter values from another cell

    Here is my solution. I can't help you with watersev's version as his way is usually like a foreign language to me.

    Sub UpdateStakes()
    Dim myRange As Range
    Dim iGroup As Long
    
    Set myRange = ActiveSheet.Range("w:w").SpecialCells(xlCellTypeConstants, xlNumbers)
    
    For iGroup = 1 To myRange.Areas.Count
        With myRange.Areas(iGroup).Resize(4, 1)
            .Offset(0, 2).Value = .Offset(-12, -11).Value
            .Offset(0, 2).FillDown
        End With
        With myRange.Areas(iGroup)
            .Cells(1, 3).Value = .Cells(1, 3).Value * 0.5
            .Cells(2, 3).Value = .Cells(2, 3).Value * 0.25
            .Cells(3, 3).Value = .Cells(3, 3).Value * 0.15
            .Cells(4, 3).Value = .Cells(4, 3).Value * 0.1
        End With
    Next iGroup
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0