Results 1 to 1 of 1

Macro to Paste Formula into Cell on Spread Sheet

Threaded View

  1. #1
    Registered User
    Join Date
    09-09-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    12

    Macro to Paste Formula into Cell on Spread Sheet

    Hi All

    I have been trying to get a Vlookup formula to match 2 Cells in a worksheet and return the corresponding value in a third Cell.

    I am trying to get the form to input the information into selected sheet "HacksPoniesDay1" then the formula needs to check cell in column Class and cell in column Place and return the corresponding value in worksheet EntriesPrizeHacksPonies.

    Private Sub New_Record_Click()
    
     Dim emptyRow As Long
     Dim emptyRow1 As Long
     Dim sheetName As String
     Dim varRange As Range
     Dim wsJumping As Worksheet
     Dim wsJumping_Results As Worksheet
     Dim wsTemp As Worksheet
     Set wsJumping = Sheets("EntriesPrizeHacksPonies")
     Set wsJumping_Results = Sheets("Show_Jumping_RESULTS")
    
       With Worksheets("EntriesPrizeHacksPonies").Cells(300, 1).End(xlUp).Offset(0, 0)
        .Offset(1, 0) = Class.Value
        .Offset(1, 1) = Class_Name.Value
        .Offset(1, 2) = Prize_List.Value
           
       End With
         
       With Worksheets(Day.Value).Cells(300, 2).End(xlUp).Offset(0, 0)
        .Offset(7, 0) = "=R[-5]C+1"
        .Offset(7, 1) = Class_Name.Value
        .Offset(7, 2) = "1st"
        .Offset(7, 5).FormulaArray = "=index(EntriesPrizeHacksPonies!A59X358,Match(RC[-6],EntriesPrizeHacksPonies!A59:A358),Match(RC[-4],EntriesPrizeHacksPonies!A58:X58,0))"
        .Offset(8, 2) = "2nd"
        .Offset(8, 5).FormulaR1C1 = "=IF(RC[-3]="""","""",VLOOKUP(R[-1]C[-5],EntriesPrizeHacksPonies!R59C[-6]:R358C24,5,FALSE))"
        .Offset(9, 2) = "3rd"
        .Offset(9, 5).FormulaR1C1 = "=IF(RC[-3]="""","""",VLOOKUP(R[-2]C[-5],EntriesPrizeHacksPonies!R59C[-6]:R358C24,6,FALSE))"
       End With
       
       
       'With Worksheets("PrizeMoneySummary")
        'lrow = .Range("C" & .Rows.Count).End(xlUp).Row
        '.Range("C" & lrow + 1).Value = Class.Value
        '.Range("D" & lrow + 1).Value = "=" & Class.Value & "!$E$2"
        '.Range("E" & lrow + 1).Value = "=" & Class.Value & "!$G$2" & "*" & Class.Value & "!$E$2"
        '.Range("G" & lrow + 1).Value = "=" & Class.Value & "!$G$4"
        
    'End With
    
    
    
        'Call UserForm_Initialize
    
    End Sub
    When I run this I get an error.

    Any help

    Thanks

    Tony
    Attached Files Attached Files

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.6.0 RC 1