Results 1 to 3 of 3
  1. #1
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402

    code syntax for excel formula

    Hi again,

    I have another excel formula that i need to convert into access vba that then creates the worksheet

    the first one I needed was - Formula1:="=MOD(MINUTE(C8:F" & Mid(last_cell, 4, 3) & "),15)>0"
    when converted into excel it looks like this in excel =MOD(MINUTE(C8:F16),15)>0
    Thanks June7
    this works great in a conditional format

    What I need now is this - =SUMIF(G8:G16, "=10",M8:M16) converted into a string excel can cope with from Access VBA.
    typed manually this works fine to sum only the rows that have 10 in the helper cell (G8:G16).

    to get the last row number of the table i'm using Mid(last_cell, 4, 3)

    so i'm guessing that it should look something like below but i can't get the syntax correct.

    =SumIF(G8:G" & Mid(last_cell, 4, 3) & ",=10" & ",M8:M" & Mid(last_cell, 4, 3) & ")"









  2. #2
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    Well so far I have this...

    In access
    When I enter this code into the VBA editor it puts FALSE in the target cell M18
    Current_Worksheet.Range("M" & Mid(last_cell, 4, 3) + 2).Formula = "=SUMIF(G8:G16," > 1 & ",M8:M16)"


    If i copy this =SUMIF(G8:G16," > 1 & ",M8:M16) from Access and remove the spaces between the " and > and 1 and remove the & it works correctly

    this works when paseted directly into the cell =SUMIF(G8:G16,">1",M8:M16)

    i'll try to get just this part working and then add the Mid(last_cell, 4, 3) to get the last table row

  3. #3
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    I got it going with this,

    Current_Worksheet.Range("$M" & Mid(last_cell, 4, 3) + 2).Formula = "=SUMIF($G$8:$G$" & Mid(last_cell, 4, 3) & "," & Chr(34) & ">1" & Chr(34) & ",$M$8:$M$" & Mid(last_cell, 4, 3) & ")"

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 41
    Last Post: 05-29-2015, 02:58 PM
  2. set excel formula from access vba
    By trevor40 in forum Programming
    Replies: 16
    Last Post: 11-26-2014, 07:32 PM
  3. How to use this formula from Excel in Access?
    By jset818 in forum Queries
    Replies: 11
    Last Post: 10-16-2014, 03:32 PM
  4. Anyone able to translate a formula from excel?
    By dniezby in forum Programming
    Replies: 10
    Last Post: 05-21-2013, 01:10 PM
  5. Syntax of a Formula using Date Part
    By Huddle in forum Reports
    Replies: 14
    Last Post: 09-25-2012, 12:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums