vba

Getfolder order by file name

无人久伴 提交于 2021-02-05 08:10:59
问题 This is my VB code for merging XML but I would like to merge it by file name. So first 1.xsl then 2.xsl How to order a list in VB? Sub simpleXlsMerger() Dim bookList As Workbook Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object Application.ScreenUpdating = False Set mergeObj = CreateObject("Scripting.FileSystemObject") 'change folder path of excel files here Set dirObj = mergeObj.Getfolder("D:\change\to\excel\files\path\here") Set filesObj = dirObj.Files For

Dynamic Criteria - Filtering Excel VBA

我只是一个虾纸丫 提交于 2021-02-05 08:10:32
问题 I need to filter on the same criteria, but the values of the criteria are not always the same in the data that I receive, so they need to be dynamic. for eg. Dim crit1 as String crit1 = ? So that: Selection.AutoFilter Field:=4, Criteria1:=crit1 here is my code enter code herexDim TaskType, Status, Elapse As Long Dim Total, Completed As Variant Total = Array("COMPLETED", "ERROR", "KILLED") Completed = Array("COMPLETED") TaskType = WorksheetFunction.Match("tasktypeid", Rows("1:1"), 0) Status =

Access 25%, 50%, 75% Quartiles (Data From Query and Result Destination is a Report)

旧巷老猫 提交于 2021-02-05 08:09:17
问题 The data that I need the quartiles is a query with the first column being the month-year and the second column being a count of defects for that month. I am looking to have the quartiles to be displayed on a report (Name: QE Quartile Test). Query name: QE Test Count Step 2 Columns names: ProductionYM ; Claims The following code is something I found online but I don't code much so I don't know where to go from here. Public Function XPercentile() XPercentile = DMin(Claims, QETest, "DCount(""*""

Run-time error 438 in Excel while using Sort function

 ̄綄美尐妖づ 提交于 2021-02-05 08:09:00
问题 I'm trying to write a code that will remove duplicates from my list. It worked well on my mac, but when I tried to run it on windows I got the runtime error 438: object doesn't support this property or method. What went wrong? Range("E2:E150").Select ActiveWorkbook.Worksheets("NOS").Sort.SortFields.Clear ActiveWorkbook.Worksheets("NOS").Sort.SortFields.Add2 Key:=Range("E2"), _ SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("NOS").Sort

Handling Recurring VBA Errors Within Subroutine

只谈情不闲聊 提交于 2021-02-05 08:00:45
问题 I am stuck on something that I have a workaround for, but it bugs me I don't have a direct answer for how to address the issue of using On Error Goto for recurring errors. My question is essentially the same as this one, however the answers provided are alternatives to the OP's overall approach rather than how to handle the specific issue. I've simplified an example below. I am WELL AWARE that there are probably a dozen ways this code could be rewritten to avoid any error -- I am just using

Update mySql table according to different conditions

丶灬走出姿态 提交于 2021-02-05 07:55:09
问题 I got this code from this site and now I need to add some change. I know I acted fool here. I searched many and got stuck in here. I wanted to add 1 to the sql table @subject column where @name is the row. @subject and @name are changing. That is why parameters used. Dim sql As String = "UPDATE attendance.student SET @subject = @subject +1 WHERE S_name = @name;” Dim conn As MysqlConnection Try conn = New MySqlConnection(ConnectionString) Dim cmd As New MySqlCommand(sql, conn) cmd.Parameters

Outlook VBA macro to search by colour category

时光毁灭记忆、已成空白 提交于 2021-02-05 07:47:26
问题 I want to make a VBA macro to search ALL folders including my online archive by colour category RED Don't have a clue where to start with this! I have a text search one but this obviously doesn't do colours. Sub SearchMacro() Dim myOlApp As New Outlook.Application txtSearch = "category:(Business)" myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders Set myOlApp = Nothing End Sub 回答1: did you tried: txtSearch = "category:=""Red category""" Complete: Sub Red() Dim myOlApp As New

How to open user interface with opening the file

旧街凉风 提交于 2021-02-05 07:47:06
问题 I am using : Private Sub start_Click() UserForm1.Show End Sub To open my user interface by pushing the start button. But, I would like my user interface to be opened automatically in the very beginning when I have just opened my excel file. Does anyone know how I can do that? 回答1: In the Workbook code pane type this Private Sub Workbook_Open() UserForm1.Show End Sub 回答2: Create a subroutine in your workbook named Workbook_Open Private Sub Workbook_Open() MsgBox "yo!" End Sub You can call

Autocomplete / drop down box for arguments past the first full stop

自闭症网瘾萝莉.ら 提交于 2021-02-05 07:46:15
问题 If I am writing an argument in Excel-hosted VBA, for example ActiveSheet.UsedRange.Select Halfway through writing the first part -- ActiveSheet -- CTRL + SPACE will autocomplete that part, or I can select the available options from a dropdown list. However- the Intellisense dropdown box and autocompletion won't work /appear for anything after the first full stop. For example I can't autocomplete the UsedRange property. Is it possible to make the suggestions appear etc. past writing the first

Excel VBA How does Excel sort duplicate values?

天涯浪子 提交于 2021-02-05 07:42:29
问题 I'm wondering how Excel would sort identical values. I have ID numbers, but there are instances where there would be a duplicate ID number. I'm unsure about how Excel would decide how to order these? Would it just look at the information in the adjacent row and then compare those values as part or the ordering? If I had: Column A | Column B 166 C 166 A 166 B And then sorted on Column A in descending order, would I get: Column A | Column B 166 C 166 A 166 B Or would I get: Column A | Column B