Checking VBA code

I apply the below function to the range that has the same dimension as x or defaultdata. However the function does not seem to work properly and returns #Value mistake. The function is run in Microsoft Office 2010.
Cant figure out why the mistake occurs. Any assistance is much appreciated
The Excel file
[code]
Function TRANS(defaultdata As Range, x As Range, numranges As Integer)
Dim bound, numdefaults, obs, defrate, N, j, defsum, obssum, i
ReDim bound(1 To numranges), numdefaults(1 To numranges)
ReDim obs(1 To numranges), defrate(1 To numranges)
N = x.Rows.Count
defsum = 0
obssum = 0
'Determining number of defaults, observations and default rates for ranges
For j = 1 To numranges
    bound(j) = Application.WorksheetFunction.Percentile(x, j / numranges)
    numdefaults(j) = Application.WorksheetFunction.SumIf(x, "<=" & bound(j), defaultdata) - defsum
    defsum = defsum + numdefaults(j)
    obs(j) = Application.WorksheetFunction.CountIf(x, "<=" & bound(j)) - obssum
    obssum = obssum + obs(j)
    defrate(j) = numdefaults(j) / obs(j)
Next j
'Assigning range default rates in logistic transformation
Dim transform
ReDim transform(1 To N, 1 To 1)
For i = 1 To N
    j = 1
    While x(i) - bound(j) > 0
        j = j + 1
    Wend
    transform(i, 1) = Application.WorksheetFunction.Max(defrate(j), 0.0000001)
    transform(i, 1) = Log(transform(i, 1) / (1 - transform(i, 1)))
Next i
TRANS = numdefaults
End Function
[/code]

I apply the below function to the range that has the same dimension as x or defaultdata. However the function does not seem to work properly and returns #Value mistake. The function is run in Microsoft Office 2010.
Cant figure out why the mistake occurs. Any assistance is much appreciated
[code]
Function TRANS(defaultdata As Range, x As Range, numranges As Integer)
Dim bound, numdefaults, obs, defrate, N, j, defsum, obssum, i
ReDim bound(1 To numranges), numdefaults(1 To numranges)
ReDim obs(1 To numranges), defrate(1 To numranges)
N = x.Rows.Count
defsum = 0
obssum = 0
'Determining number of defaults, observations and default rates for ranges
For j = 1 To numranges
    bound(j) = Application.WorksheetFunction.Percentile(x, j / numranges)
    numdefaults(j) = Application.WorksheetFunction.SumIf(x, "<=" & bound(j), defaultdata) - defsum
    defsum = defsum + numdefaults(j)
    obs(j) = Application.WorksheetFunction.CountIf(x, "<=" & bound(j)) - obssum
    obssum = obssum + obs(j)
    defrate(j) = numdefaults(j) / obs(j)
Next j
'Assigning range default rates in logistic transformation
Dim transform
ReDim transform(1 To N, 1 To 1)
For i = 1 To N
    j = 1
    While x(i) - bound(j) > 0
        j = j + 1
    Wend
    transform(i, 1) = Application.WorksheetFunction.Max(defrate(j), 0.0000001)
    transform(i, 1) = Log(transform(i, 1) / (1 - transform(i, 1)))
Next i
TRANS = numdefaults
End Function
[/code]
Hi Jimmy,
We will need more information in order to be able to help you. Such as sample input data, sample output data. What the function is trying to do. You can't just expect to throw code at us and expect us to solve the issues!
John

Similar Messages

  • Excluding VBA codes from grammar & Spell checker in word 2013

    hi Guys
    i am learning VBA & i write my notes & my exercises in a word document.
    the problem is Grammar & spell checker shows VBA codes as errors.
    i don't want to completely disable checker. is there any method or Add-on so that we introduce Correct VBA codes as correct sentences to word 2013 so that it doesn't show them as errors ?
    thanks in advanced

    i tested it but i noticed an strange behavior. it sometimes works but sometime doesn't. or sometime partially works.
    for example i have defined a box as a border around the selected Area. this applies but although i have selected "do not check spelling or grammar" , system again shows spelling & grammar errors as you see in the screenshot. it's seen even
    after i reapply style. any further help please?
    Your screenshots have far too little resolution to see anything meaningful. I cannot see what Style you're applying the attributes to, or how you're using that Style. If you're applying the Style to text that's already in the document, you may need to run the
    spell-checker to clear the 'error' underlining that was already there.
    Cheers
    Paul Edstein
    [MS MVP - Word]
    i have created the "NOGrammarSpellCheck" Style correctly.
    yes i had written some VBA codes in my doc, then i created my "NoGrammarCheck" Style & Applied it on the selected Exiting codes. but again errors are shown. i noticed that when i again click on my style to apply, know errors disappear.
    so i found that if codes exit before, we must apply the
    "NoGrammarCheck" Style Twice so that it completely be applied.
    but if we Apply the style on a blank area in word doc & then paste our VBA codes in that Area, now everything is ok & no grammar or spell check is shown.
    am i correct ?

  • VBA code to update Excel Data in sharePoint list

    hi Team,
    I have excel sheet created having data. I need to upload it in sharepoint List.
    Please provide me VBA code for the same.

    Please try this.
    Sub UpdateSpecificCells()
    'If nobody has the file checked out
    If Workbooks.CanCheckOut("http://excel-pc:43231/Shared Documents/ExcelList.xlsb") = True Then
    Application.DisplayAlerts = False
    'Open the file on the SharePoint server
    Workbooks.Open Filename:="http://excel-pc:43231/Shared Documents/ExcelList.xlsb", UpdateLinks:=xlUpdateLinksNever
    ActiveSheet.Cells(2, 7).Value = 100
    ActiveSheet.Cells(3, 7).Value = 200
    ActiveSheet.Cells(4, 7).Value = 300
    'Close the workbook
    Workbooks("ExcelList.xlsb").Save
    Workbooks("ExcelList.xlsb").Close
    End If
    End Sub
    I haven't used SharePoint in many years, and I can't test that code now, but I've used that before to update Excel files in SharePoint.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • Access 2000 with VBA code doesn't work in Access 2013

    I have a database that was created in Access 2000 with lots of VBA code to pull data from SQL for reports. When I try to run a report in 2013, I get 'file not found".  When I go into debug, it appears the forms for the reports are not being found. 
    How can I fix this?

    Good Morning MariS2,
    Did you verify the change in the connection type?
    Did you check all your references which are changed for the new version of Access?
    Just takes a click to give thanks for a helpful post or answer.
    Please vote “Helpful” or Mark as “Answer” as appropriate.
    Chris Ward
    Microsoft Community Contributor 2012

  • VBA code not working in SEM-BPS 3.2

    We are currently running on BW 3.1 and SEM-BPS 3.2 environment. I am trying to create a screen in excel with VBA code doing validation on user input. For some reason the code works perfectly fine in standalone Excel. But when it comes to BPS, the code does not work. Is there any setting to invoke the code? Any help would be greatly appreciated.
    Thanks

    Bindu,
    Thanks for your reply. I checked in the layout builder and both the VBA Macro - SAPAfterDataPut and SAPBeforeDataGet are checked. Below is the code:
    Thanks again!
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("D1:D1000")) Is Nothing Then
        If Target.Value = "183998" Or Target.Value = "192999" Or Target.Value = "0000183998" Then
        ActiveSheet.Unprotect
        On Error Resume Next
        'Application.EnableEvents = False
        MsgBox "You cannot plan on TPIs 0000183998 Or 0000192999"
        Target.ClearContents
        'Application.EnableEvents = True
        ActiveSheet.Protect
      End If
    End If
    End Sub

  • BRF expression to check company code in SC

    Hello,
    I need to check company code in SC as a starting condition. There is standard expression 0V_IN_COMPANYCODE to check Company code in Invoice with those parameters :
    Result Type : C
    Access FM : /SAPSRM/WF_BRF_0EXP000
    0C_C1_C_FWFINRLCNTNT     Class: /SAPSRM/CL_WF_RULE_CONTXT_INV     C     30
    0C_C2_C_GET_PROPERTY     Method - Get Atrribute Value     C     12
    0C_C3_C_COMPANYCODE     Company Code     C     30
    I created a Z expression Z_SC_COMPANY with SC class and those parameters :
    Result Type : C
    Access FM : /SAPSRM/WF_BRF_0EXP000
    0C_C1_C_FWFSCRLCNTNT     Class: /SAPSRM/CL_WF_RULE_CONTXT_SC     C     28
    0C_C2_C_GET_PROPERTY     Method - Get Atrribute Value     C     12
    0C_C3_C_COMPANYCODE     Company Code     C     30
    In an other expression I check Z_SC_COMPANY = '1234' And it does NOT work.
    Any idea why?
    Thanks in advance.

    Hi,
    Please go to SWO1 transaction and check attributes for BUS2121 and BUS2205.
    You pass Company Code parameter which does not exist in SC. System can not get value from Business Object.
    You can create sub object and add attributes in SC Business Object if you need to use standard FM.
    Regards,
    Masa

  • The BEx Analyzer cannot generate VBA code due to the security settings

    Hello experts,
    when I try to open a query in BEx Analyser I get this error message for each Item of the Query:
    Diagnosis
    The BEx Analyzer cannot generate VBA code due to the security settings.
    System Response
    VBA code is not generated.
    Procedure
    Choose Tools -> Macro -> Security.
    On the Trusted Publishers tab page, select Trust access to Visual Basic project.
    Choose OK.
    Close the BEx Analyzer and continue working as before.
    Access to Visual Basic project is only needed when generating VBA code.
    This only takes place in design mode or when 3.x workbooks are upgraded.
    Of course I did exactly what was recommanded in the "procedure-section" of this error message. But BEx ist still not working!
    I use SAP NetWeaver 7.0 together with MS Excel 2007
    Thanks
    Axel

    Hello experts,
    I am an additional person interested in the way this issue was solved.
    I confirm that the issue is coming from the SP2 of Microsoft Office (I have another environnement without the SP2 and everything works well), and I am in a situation where I can't remove the update.
    Regards
    Guillaume P.
    EDIT :
    Solution found : I applied the bi710sp10p_1001-10004472.exe patch
    (downloaded via the download maanger : Support Packages and Patches - Entry by Application Group" SAP Frontend Components" BI ADDON FOR SAP GUI" BI 7.0 ADDON FOR SAP GUI 7.10)
    Edited by: GUILLAUME PETIAUX on Apr 13, 2010 10:29 AM

  • PO creation-ME21n-Why SAP does not check company code and Plant relation

    Hi All,
    Does someone know, why SAP does not check Plant and company code relation at the time of PO creation or how can we put validation between plant and company code at the time of PO creation.
    <b>Example:</b> Suppose i have a company 0001 which is assinged to Plant 0001. when i am creating a PO with another company code 0002(Entering at header level-Org, data) and using Plant 0001 at line item level. SAP does not do this validation.
    How can we put this check in place?
    Thanks in advance.
    Deepak

    Hello Deepak,
    There are three types of purchasing
    - Company code specific :You need to assign company code to Pur organization
    - Plant specific : You must assign plant to pur organization
    - Cross company purchasing: No assignment between company code and pur organization.
    In the case 3, the system will not check company code and plant relationship, but it will check plant and pur organization specific.
    The following is the copy of sap help text:
    You can assign a purchasing organization to one company code. This is company-specific purchasing.
    You can assign a purchasing organization to no company code. This purchasing organization can then procure for all plants assigned to it, irrespective of the company code to which the plant belongs.
    Since each plant must be assigned to a company code, the company code can be determined via the plant in each procurement transaction, even if the procuring purchasing organization is not assigned to a company code.
    A purchasing organization must be assigned to one or more plants. This is plant-specific purchasing.
    Now, check your company-code and purchase organization assignment.
    Hope this helps.
    Regards
    Arif Mansuri

  • I didnt konw how to make a new account for my iTues card so i did it with a diffrent email but that email doesnt exist and when i tried to make it on a real email i just sai invalid code check the code and try again and can u please help me

    please help me it is a card of 25 dollars and i dont want it to go to waist i by mistake thought you used a frake email so i made one up i thought i was going to have a new one but then it said it was going to send a verifaction to my email so then i tried to use a real email and put in the code but it just kept on saying invalid code. check the code and try again. and i dont know what to do can u please please help me it was a gift and i really dont want it to go to waist please i need help

    for #1
    Frequently asked questions about Apple ID - Apple Support
    I have multiple Apple IDs. Is there a way for me to merge them into a single Apple ID?
    Apple IDs cannot be merged. You should use your preferred Apple ID from now on, but you can still access your purchased items such as music, movies, or software using your other Apple IDs.
    If you are wondering how using multiple Apple IDs relate to iCloud, see Apple IDs and iCloud.
    for #2
    Apple does not accept unsolicited ideas see Apple - Legal - Unsolicited Idea Submission Policy

  • How to track changes of VBA Code in AO?

    Hi Community,
    is it possible to track changes of VBA code in Excel or AO. Is there any future for that?
    Does anybody have experience with that?
    Thanks
    Andreas

    Hi,
    there exist also no possiblity to get some Infos from the "Microsoft
    Office Alerts?
    Thanks Andreas

  • Apple TV keeps asking my for my Credit Card verification code and I punch it in, still asks me for it, and restarted everything, went to my computer, checked the code, all is set, still can't rent a movie. Please help!

    Apple TV keeps asking my for my 3digit  Credit Card verification code and I punch it in, it still asks me for it, and went to my computer on iTunes store, checked the code, all is set and saved, go back to Apple TV still can't rent a movie, I still get the same Verification Required message without any further information after I punch in my 3digits. When I hit submit, the page goes back to the same place to type the code again, and yes the code is 100% accurate. I tried restoring the apple tv, every thing is up to date on all devices and signed in and out of my itunes store on my Mac, still no luck. Please help!

    This issue actually started a week ago... see: https://discussions.apple.com/message/23399558#23399558
    to determine if there are the same problems you are experiencing.  I have spent over 6 hours on this issue trying to isolate if it is a hardware, software, network, iTunes account, or Apple device issue.  My initial results indicate it is a software specific issue related to the Apply TV hardware device.

  • Please check the code

    I AM TRYING TO REPLICATE THE ADDRESS OF EQUIPMENT FROM ECC TO CRM.
    I AM ABLE TO REPLICATE THE IDENTIFICATION NUMBER.
    WHILE USING THE SAME FUNCTION MODULE FOR ADDRESS, THE ADDRESS IS NOT GETTING REPLICATED.
    PLEASE CHECK THE CODE AND TELL ME WHAT PRE-REQUISITES MUST BE TAKEN INTO CONSIDERATION AND IS THERE ANY MISTAKE FROM ME.
    FULL POINTS WILL BE REWARDED.
    ITS VERY VERY URGENT.
    METHOD IF_EX_CRM_EQUI_LOAD~ENLARGE_COMPONENT_DATA.
    **Data declarations
    DATA:
        ls_equi          type crmt_equi_mess,
        ls_comp          type ibap_dat1,
        ls_comp_det1     TYPE IBAP_COMP3,
        ls_address_data  type ADDR1_DATA,
        ls_object      type comt_product_maintain_api,
        ls_object1     type comt_product,
        lv_object_id   type IB_DEVICEID,
        lv_object_guid type IB_OBJNR_GUID16.
    **Map Sort field from ECC to CRM
    Read table it_equi_dmbdoc-equi into ls_equi index 1.
    lv_object_id  = ls_equi-equnr.
    move is_object to ls_object.
    move ls_object-com_product to ls_object1.
    lv_object_guid = ls_object1-product_guid.
    move is_component to ls_comp.
    ls_comp_det1-deviceid    = lv_object_id.
    ls_comp_det1-object_guid = lv_object_guid.
    ls_comp_det1-EXTOBJTYP   = 'CRM_OBJECT'.
    ls_comp_det1-ibase       = ls_comp-ibase.
    ls_address_data-roomnumber = '1000'.
    ls_address_data-floor = '10'.
    ls_address_data-country = 'US'.
    CALL FUNCTION 'CRM_IBASE_COMP_CHANGE'
      EXPORTING
       i_comp                       = ls_comp
       I_COMP_DET             = ls_comp_det1
       I_ADDRESS_DATA     = ls_address_data
      I_ADDRESS_ADMIN           =
      I_PARTNER                 =
      I_DATE                    =
      I_TIME                    =
    EXCEPTIONS
      DATA_NOT_CONSISTENT       = 1
      IBASE_LOCKED              = 2
      NOT_SUCCESFUL             = 3
      OTHERS                    = 4
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    ENDMETHOD.

    Hi S B,
    May I the procedure for the replication of serialnumber into device ID that is Identification field In Ibase.
    And one more thing need this to be codded in the standard badi or needed an copy of the implementation .
    plz help me as u already have done the requirement.
    u will be twice rewarded.
    Thanking u in advance for the reply.
    Sree.

  • Extract image in PDF file - vba code in Excel

    Hi All,
    I am applying a solution for my company. We have some Front offices which receive customers' requests in paper form.
    We have one Back Office which is receiving the customers' original paper requests from Front Office via courier mail.
    To improve the efficency, I am trying to apply a solution which allow the Front Offices to scan the paper requests into PDF files.
    Those scanned files will be accessed by Back Office to process.
    Given the volume of the requests, it is impossible to open each file in the folder by clicking mouse.
    I have completed the tool (using Excel and vba ) which displays all of the requests (PDF files) as hyperlinks in Excel list.
    The requests are ranked with priority so that the Back Office people know which to process first.
    That solution works well.
    However, Back Office has just requested me to display certain fields in the PDF files as image in Excel's cells so that they can type the information to the system without having to open the PDF files.  The way that the images are displayed on Excel cells is an extraction of part of PDF page.
    I know that in Adobe Reader, I can use my mouse to select part of the area then copy to clipboard, so I hope that we can do the extraction programmatically.
    Could anyone can help me figure out how to implement above extraction solution in Excel vba?
    I am facing 2 concerns:
    1. Acrobat SDK:
    I don't know if my company purchased license of Acrobat SDK or not.  But when I open Excel VB editor, I can see in "Reference" menu the below items:
       + Adobe Acrobat Browser Control Type Library 1.0
       + Adobe Acrobat 9.0 Type Library
       + Acrobat Access 3.0 Type Library
    Are the above enough for my application?
    2. VBA code for extraction of part of PDF files:
    - What should be on the vba code for the extraction?  Which functions I should use?
    Thank you very much
    Cheers

    The functionality that you require is not available to VBA/COM - it is only exposed via C/C++.
    However, you could retrieve the ENTIRE page image to the clipboard and then use whatever VB/VBA methods you choose to grab a section of the image.
    Of course, this all assumes that Adobe Acrobat is installed on each person's computer that will be using the solution since Reader does not have the necessary APIs and Acrobat can't be installed on a server.

  • MAC VBA Code workbook close only works when breakpoints are set - fails when no breakpoints

    We have an Excel Product that we are trying to get to work on the Mac.  One of the worksheets displays a disclaimer, and if the user clicks on the I Don't Accept radio button and then clicks next, the workbook is supposed to close itself.  The
    code is quite simple:
    Public Sub HandleNextButton()
        Dim filename As String
        Dim opened_workbook As Workbook
        If AcceptsDisclaimerChecked Then
            FinishSetup
        Else
             ThisWorkbook.Saved = True ' Realize this is redundant based on false on the next line.
             ThisWorkbook.Close False
          End If
    End Sub
    All of our product sheets are protected by a block of code attached to the Workbook_BeforeClose event:
     Only allow a save if privileged, otherwise mark the workbook as saved
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        On Error Resume Next
        If ThisWorkbook.Saved Then Exit Sub
        ' If this user is not allowed to save, then cancel the save
        CM_Settings = LoadRegistrySettings
        If (CM_Settings And 4096) = 0 Then
            Me.Saved = True
        Else
           ' If the workbook is saveable, then turn on the image to protect the data.
           ' saving the workbook triggers the Workbook_BeforeSave which shows the veil
           Me.Save
        End If
    End Sub
    This works fine on the PC.  On the Mac, the workbook does not close.  I can see the button fire, and when it gets to the point where the workbook is to be closed, nothing happens.
     However, when I put a break point on the first line of the Workbook_BeforeClose, I can briefly see it reach the breakpoint (the line turns yellow), and then the workbook immediately closes.  A breakpoint anywhere in this routine causes the same
    behaviour, the close works correctly.  No breakpoint, no close.  Commenting out the Resume Next has no effect.  The only thing that will cause the work book to close, is to put a break point on on the On Error Resume Next in the code.  If
    the workbook.Saved=True is commented out, the Workbook_Close code will exit, at the first if statement, but the workbook will not close.
    Does anyone have any clues to this bizarre behaviour?
    Thanks, Neil
    Neil M. Johnson

    There is a difference between MAC and Windows based VBA code. I'd suggest asking MAC related questions on the
    Office for Mac  forum instead. The current forum is for Windows based developers.

  • How to get active user data using vba code in excel

    Start with this script: http://community.spiceworks.com/scripts/show/1572-list-user-info-in-excel
    Then add an extra line to get the msDS-UserAccountDisabled attribute, or test for it in an If/Else block.

    Could you please help me to get only active user details from active directory using vba code.
    Any help would be immensely appreciated.
    Thanks in advance
    This topic first appeared in the Spiceworks Community

Maybe you are looking for

  • Multiple iCloud accounts on one Mac

    I would like to set up an ical calendar to sync all the schedules of my family members. We all have iCloud accounts. This worked before in mobileme, but since the iCloud upgrade it no longer works. Any suggestions to get this working again?

  • IChat Video Not Working? 2012

    I have... Mac OS X Version 10.6.8 MacBook Pro My iChat is connected to Gmail. My iChat allows video and voice calls. However, when I try to make any call, the buttons below are idle. Meaning, it cannot be pressed. The idle buttons look like this: See

  • Have a mac more than 5 years old need to update software but i dont know how? what update do i need? any help appreciated.

    im trying to update the softare on my mac book, initially itunes but it wont update due to the software being behind. since my mac book is more than 5 years old i cant get the support from the apple website. so some knowledge from the community would

  • Sorting the Message Array

    Hi Does anyone know whats the best way to sort an array of Message[] after getting this array from the Folder. Sorting by date is straight forward (ie sort by msg #, ascending / descending). How about sorting by FROM, SUBJECT or SIZe (in each case as

  • ActiveDirectory module, how to authenticate to an outside AD environment?

    I have an interesting problem and I'm not sure how to work around it. My AD environment is Windows 2008 R2. My workstation in Windows 8.1 NOT joined to active directory. I need to run/develop some PS scripts that use the ActiveDirectory module, howev