excel-vba

Creating an MS Excel file which deletes itself when a certain time or date is reached

时光总嘲笑我的痴心妄想 提交于 2020-06-11 06:47:39
问题 Regarding MS Excel, I want to know how to create an Excel file that is deleted from the computer when a certain date or time is reached. Is it possible? If it is, please tell me how it can be done? 回答1: You can call function DoSomething at a certain time in the future or by specifying the time interval by calling Activate_timer , but I don't think you can delete workbook direct from VBA. You can try to call in DoSomething function some batch file which closes the book first and then remove it

Is there an Excel Function to find a combination of numbers

筅森魡賤 提交于 2020-06-11 05:18:45
问题 I am not familiar with all of excel's functions and data tools, though I am familiar with excel. My problem is that I have a number on a spreadsheet which is a combination of many different numbers on a list. For example: A list contains: 100, 200, 250, 500, and 1000, and the number I need to explain is: 800 The answer would be 500, 200, 100 . Not hard to do in my head for a short list with simple numbers, but I'm dealing with over 1500 currency cells ($xxxx.xx) which make a total ( and not

Is there an Excel Function to find a combination of numbers

梦想与她 提交于 2020-06-11 05:18:02
问题 I am not familiar with all of excel's functions and data tools, though I am familiar with excel. My problem is that I have a number on a spreadsheet which is a combination of many different numbers on a list. For example: A list contains: 100, 200, 250, 500, and 1000, and the number I need to explain is: 800 The answer would be 500, 200, 100 . Not hard to do in my head for a short list with simple numbers, but I'm dealing with over 1500 currency cells ($xxxx.xx) which make a total ( and not

ExportAsFixedFormat fails sometimes

ぃ、小莉子 提交于 2020-06-10 16:11:26
问题 I have a spreadsheet with forms and macros that worked until recently. The first time I saw the described behavior was the first time I tried using this particular function in Excel 2016 (Windows 10), though I'm not sure that's the cause. The issue I'm having is with the following line Worksheets("Label Template - 100X150").ExportAsFixedFormat Type:=xlTypePDF, _ Filename:=pdfFilePath, Quality:=xlQualityMinimum, _ IncludeDocProperties:=False, _ IgnorePrintAreas:=False, OpenAfterPublish:=True

Copy data from a Pivot table in one worksheet ot another

痞子三分冷 提交于 2020-06-09 03:02:06
问题 I have two workbooks; in one I have a Pivot table; in the other, an empty worksheet. I am trying to copy certain data from the pivot table to the other workbook, but it seems like VBA isnt copying my selection. Currently I have written: With cevesa.Worksheets("r_hora") On Error Resume Next .PivotTables("r_hora").PivotFields("PARAM").ClearAllFilters .PivotTables("r_hora").PivotSelection = "PARAM['DEM(MW)':'DEM_AGREGADA(MW)','POT(MW)':'POT_HID(MW)','POTDESP(MW)']" Selection.Copy analisis

Copy data from a Pivot table in one worksheet ot another

蹲街弑〆低调 提交于 2020-06-09 03:01:50
问题 I have two workbooks; in one I have a Pivot table; in the other, an empty worksheet. I am trying to copy certain data from the pivot table to the other workbook, but it seems like VBA isnt copying my selection. Currently I have written: With cevesa.Worksheets("r_hora") On Error Resume Next .PivotTables("r_hora").PivotFields("PARAM").ClearAllFilters .PivotTables("r_hora").PivotSelection = "PARAM['DEM(MW)':'DEM_AGREGADA(MW)','POT(MW)':'POT_HID(MW)','POTDESP(MW)']" Selection.Copy analisis

Worksheet Change Event Stuck in Infinite Loop

此生再无相见时 提交于 2020-06-01 07:32:09
问题 I want the following code to do the following: after I enter a value into a specific column, calculate some stuff and assign cell values with those calculated values Problem: the Worksheet.Change event will fire again after I assign a value to another cell, which restarts the sub and causes an infinite loop How do I change my code such that it doesn't get stuck in an infinite loop and the cells I want to be updated will automatically update whenever I add a value to the column I'm working

dropdown list with autocomplete/ suggestion in excel vba

☆樱花仙子☆ 提交于 2020-06-01 03:34:04
问题 In a merged cell (named as SelName) I have a dropdown list with more then 100 items. Searching through the list is not efficient, as this list is constantly growing. Therefore, I would like to have a dropdown list with autocomplete/ suggestion function. One of the codes that I have is the following which I have found on extendoffice.com: Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'Update by Extendoffice: 2017/8/15 Dim xCombox As OLEObject Dim xStr As String Dim xWs As

Launch Excel and Reference UserForm object from MS Access

一曲冷凌霜 提交于 2020-05-31 06:16:09
问题 I have an MS Access database application here and I'd like to launch an Excel file using VBA and populate fields on a UserForm object within this file with default values. I'm struggling to find the syntax I can use to reference the UserForm object from outside the Excel application. Hopefully this makes sense. Here's my simple code so far. Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook Set xlApp = CreateObject("Excel.Application") Set xlWB as xlApp.Workbooks.Open("[My file path

VBA - call function without return variable

余生颓废 提交于 2020-05-29 06:42:46
问题 i have function: Function importCSV(fileName As Variant) As Boolean ' some code ' no importCSV = TRUE end Function i call this function importCSV (fileName As Variant) every do OK, bud when a modific function. Function importCSV(fileName As Variant, linkToHeader As Boolean) As Boolean ' some code ' no importCSV = TRUE end Function i cant call function like this importCSV (fileName As Variant, TRUE) VBA detect syntax error and a must call a = importCSV(fileName As Variant, TRUE) Why? 回答1: To