excel

Subscript out of range — Unable to set open workbook as active workbook

旧时模样 提交于 2021-02-05 08:34:09
问题 I'm trying to copy two cells B2 & C2 from the Results worksheet on every single workbook within a folder and then paste cells in a Master workbook starting in cell A1, A2, A3 etc I'm getting the error Subscript out of range it isn't highlighting anything specific but I'm assuming it's because the workbook the macro is running from doesn't have a 'Results' sheet. It's opening the correct workbook Workbooks.Open (Filepath & MyFile) but I don't seem to be able to set the newly opened workbook as

Structured References: Absolute and Relative addressing

只愿长相守 提交于 2021-02-05 08:31:22
问题 This is a "weighted average" formula where Q14:Q21 contains the "weights"; Column C is the first column of data, and subsequent columns are D:P I can use this formula, and fill right. The data columns will change and the "weight" column remain the same. =SUMPRODUCT(Sheet1!C$14:C$21,Sheet1!$Q$14:$Q$21)/SUM(Sheet1!$Q$14:$Q$21) I would like to change the data to a "table" so as to be able to use structured references. The "weights" column header is Percent , and the data columns are year numbers

Maximum Value Based on a Condition

别来无恙 提交于 2021-02-05 08:29:51
问题 I have a mock dataset in Excel that I want to print the most recent date, but I want it to be the latest date such that the Type is "referral": Type Date referral 1/6/2017 classroom 1/7/2017 referral 1/8/2017 classroom 1/9/2017 What would that function look like? 回答1: You can use an array formula like this (assuming your columns are A and B): =MAX(IF(A2:A5="referral",B2:B5)) and enter it by pressing Ctrl + Shift + Enter (CTRL+SHIFT+ENTER). When entered by Ctrl + Shift + Enter , Excel will put

Maximum Value Based on a Condition

余生颓废 提交于 2021-02-05 08:27:27
问题 I have a mock dataset in Excel that I want to print the most recent date, but I want it to be the latest date such that the Type is "referral": Type Date referral 1/6/2017 classroom 1/7/2017 referral 1/8/2017 classroom 1/9/2017 What would that function look like? 回答1: You can use an array formula like this (assuming your columns are A and B): =MAX(IF(A2:A5="referral",B2:B5)) and enter it by pressing Ctrl + Shift + Enter (CTRL+SHIFT+ENTER). When entered by Ctrl + Shift + Enter , Excel will put

Keeping cell references the same when applying formula to entire column

北战南征 提交于 2021-02-05 08:21:04
问题 I have this formula here: =IFERROR(IF(D4<=0,0+(VLOOKUP(A4,'Civil Maintenance'!A5:C46,3,FALSE)),_ C4+(VLOOKUP(A4,'Civil Maintenance'!A5:C46,3,FALSE))),"0") As you all know when you drag it down to copy the formula to other cells in the column, it adds one to all the references (D4 becomes D5 etc.) However i was wondering if there's a way to stop this for certain parts? I want to keep the lookup search area the same so that A5:C46 stays the same in all formulas of the column but i still want

Getfolder order by file name

本小妞迷上赌 提交于 2021-02-05 08:11:12
问题 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

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 =

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

Excel - Formula to create an array of lookup values based on a criteria

天涯浪子 提交于 2021-02-05 07:59:06
问题 I was looking for the solution for this apparently easy problem, but failed so far. I have a table in Excel like this: Column 1 Column 2 apples 1 apples 2 bananas 5 apples 3 bananas 4 What I need is a formula that returns an array of the values in column 2, based on the criteria on column 1. So if I choose "apples", my output array should be {1,2,3}. That output should be compatible for use inside of a standard SUM(SUMIFS()) formula. Thanks in advance for any insight Regards, André Edit: The