vba

Search for an element in the VBA ArrayList

爷,独闯天下 提交于 2021-02-10 18:23:56
问题 I hope you are great! I want to search through a VBA ArrayList and get the index number, the problem is, with For loop, you can only get the exact matches' index. I have the most of my search element (highlighted in the red box) and I want to get the elements which highlighted in the blue box, is there any way to do this in VBA? 回答1: You can use the in-built function InStr to find an occurrence of one string inside another. In your case change this: If list(j) = search_element Then To: If

convert CURL request into VBA xml Object in MS-Access

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 18:17:08
问题 I am trying to handle moodle data from our schools MS-Access database using VBA-code to post xml.objects. I implemented the following code from an example for using the RESTful-API into my VBA-code (source https://moodle.org/plugins/webservice_restful): json code: curl -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -H 'Authorization: {token}' \ -d'{"options": {"ids":[6]}}' \ "https://localhost/webservice/restful/server.php/core_course_get_courses" This is my

Outloook VBA macro to reply all with oft template

与世无争的帅哥 提交于 2021-02-10 18:00:38
问题 I have a macro built for VBA Outlook where I can reply all, using an attachment. This is the code: Sub Estimate() Dim origEmail As MailItem Dim replyEmail As MailItem Dim s() As String Dim add As String Set origEmail = Application.ActiveWindow.Selection.Item(1) Set replyEmail = Application.CreateItemFromTemplate("C:\template.oft") s = Split(origEmail.CC & ";" & replyEmail.CC, ";") replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody replyEmail.Subject = "RE: " + origEmail

Force the creation and “looping” of single element arrays? (VBA)

自闭症网瘾萝莉.ら 提交于 2021-02-10 18:00:28
问题 I hope to find a compressed solution to array handling over having to duplicate large sections of code only to handle lists of 1 element. (0 element is not a big problem because that needs no execution) If I create testRange As Variant testRange = .ListColumns(2).DataBodyRange.Value2 'Case only 1 row in list IsArray(testRange) 'FALSE! I have tried testRange() As Variant testRange() As String ... Is there a way to force VBA to create Array also if only 1 elements are fed? After that is there a

Outloook VBA macro to reply all with oft template

烈酒焚心 提交于 2021-02-10 17:59:16
问题 I have a macro built for VBA Outlook where I can reply all, using an attachment. This is the code: Sub Estimate() Dim origEmail As MailItem Dim replyEmail As MailItem Dim s() As String Dim add As String Set origEmail = Application.ActiveWindow.Selection.Item(1) Set replyEmail = Application.CreateItemFromTemplate("C:\template.oft") s = Split(origEmail.CC & ";" & replyEmail.CC, ";") replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody replyEmail.Subject = "RE: " + origEmail

Force the creation and “looping” of single element arrays? (VBA)

℡╲_俬逩灬. 提交于 2021-02-10 17:58:54
问题 I hope to find a compressed solution to array handling over having to duplicate large sections of code only to handle lists of 1 element. (0 element is not a big problem because that needs no execution) If I create testRange As Variant testRange = .ListColumns(2).DataBodyRange.Value2 'Case only 1 row in list IsArray(testRange) 'FALSE! I have tried testRange() As Variant testRange() As String ... Is there a way to force VBA to create Array also if only 1 elements are fed? After that is there a

Run macro when slicer change

▼魔方 西西 提交于 2021-02-10 17:45:55
问题 I can't get the macro to automatically run when an item in a slicer (from a chart) is selected. I tried by adding the code under a private sub or even public function but still can't get the click/selection of an item in the slicer to trigger the macro. I tested the sub Slicer_Opt and it works when I have an item selected and I run it manually, but as I said, I can't get it to automatically trigger when I select an item in the slicer. Until now I have the following: Public Function

Date diff between many rows in Excel

試著忘記壹切 提交于 2021-02-10 17:38:38
问题 I have USER_ID, EVENT_ID and DATE and I need to check which of the events are real. Real event is the first one by each user and every one which is at least 10 days after the last real event. What i do is to order them by USER_ID and date and using this forumla =IF(A2<>A1;1;IF(C2-C1>=10;1;0)) but that way it calculates date diff between current and the previous event, not to the last real event. Like if i have events at 01 05 and 13 from one user it will give me 1, 0, 0 but i need to compare

Stop in Close and Open userforms _VBA

六月ゝ 毕业季﹏ 提交于 2021-02-10 16:51:40
问题 I created two forms. Pressing the button 1 opens the form number 2. By closing the form number 2, the form number 1 is displayed. But this action is only done once and it stops for the second time and almost does not work. Where does the code have a problem? code Userform1: Private Sub ShowUserform2_Click() UserForm1.Hide Unload UserForm1 UserForm2.Show End Sub Code userform2: Private Sub UserForm_Terminate() UserForm2.Hide Unload UserForm2 UserForm1.Show End Sub 回答1: Skip the formName.Hide

Stop in Close and Open userforms _VBA

纵饮孤独 提交于 2021-02-10 16:48:52
问题 I created two forms. Pressing the button 1 opens the form number 2. By closing the form number 2, the form number 1 is displayed. But this action is only done once and it stops for the second time and almost does not work. Where does the code have a problem? code Userform1: Private Sub ShowUserform2_Click() UserForm1.Hide Unload UserForm1 UserForm2.Show End Sub Code userform2: Private Sub UserForm_Terminate() UserForm2.Hide Unload UserForm2 UserForm1.Show End Sub 回答1: Skip the formName.Hide