excel-vba

Saving Excel data as csv with VBA - removing blank rows at end of file to save

十年热恋 提交于 2020-01-11 09:32:30
问题 I am creating a set of csv files in VBA. My script is creating the data set I need, but the number of rows differs in multiple iterations of the loop. For instance, for i=2, I have 100,000 rows, but for i=3, I have 22,000 rows. The problem is that when Excel saves these separate csv files, it does not truncate the space at the end. This leaves 78,000 blank rows at the end of the file, which is an issue given that I need about 2,000 files to be generated, each several megabytes large. (I have

Saving Excel data as csv with VBA - removing blank rows at end of file to save

人盡茶涼 提交于 2020-01-11 09:32:09
问题 I am creating a set of csv files in VBA. My script is creating the data set I need, but the number of rows differs in multiple iterations of the loop. For instance, for i=2, I have 100,000 rows, but for i=3, I have 22,000 rows. The problem is that when Excel saves these separate csv files, it does not truncate the space at the end. This leaves 78,000 blank rows at the end of the file, which is an issue given that I need about 2,000 files to be generated, each several megabytes large. (I have

Excel VBA quit Word document

北慕城南 提交于 2020-01-11 09:22:06
问题 I have a macro that inserts select cells of an Excel document into a Word template, copies the entire Word document then closes the document without saving, to preserve certain keywords. However when it closes the Word document it leaves a blank Word window open, with no active document, and each time the macro runs it leaves a new blank window. Dim appWd As Word.Application Dim wdFind As Object Dim ClipEmpty As New MSForms.DataObject Dim ClipT As String Sub CopyDatatoWord() Dim docWD As Word

Save as PDF in Landscape

扶醉桌前 提交于 2020-01-11 08:59:08
问题 How can I pdf multiple sheets in my Workbook into one pdf in landscape format? Here is what I have. I am missing the landscape syntax - Sub CompileReport() Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="F:\Report\Test" & ".pdf", _ Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False End Sub Thanks! 回答1: Try this one: Sub CompileReport() Dim mySheets As Variant, sh mySheets = Array("Sheet1", "Sheet2",

Importing Files Into Excel - Skip if not Found

你离开我真会死。 提交于 2020-01-11 07:51:30
问题 This is my first question here, I have a macro to import .txt files "Semicolon" delimited into Excel. Each file is name specific, and each file is imported in a new sheet. But if one of theses files doesn't exists, the macro Fails. I want to add an "On Erro" to handle these cases, if the file doesn't exists, skip it. Heres the code: Sub Importar_Dep() Dim Caminho As String Caminho = Sheets("DADOS").Cells(5, 8).Value Sheets("DEP").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;"

Get the data from excel files in sub directories

时光总嘲笑我的痴心妄想 提交于 2020-01-11 07:26:30
问题 I am new to VBA and to programming in general. This is my first post on this board. I've been working on this for a while modifying code I've found on the internet and I have the code to do what I want, however I would like to modify it slightly to speed up the process. The code I have pulls data from excel files that I deposit in a folder on my desktop "Receiving Temp" and places the data in a workbook "Receiving Data Extractor". I am getting data from about 1000 files a month which are

My ComboBox doesn't display the values I've added in VBA

女生的网名这么多〃 提交于 2020-01-11 07:04:54
问题 I'm trying to add options to a combo box in a userform. When I run the code, Excel doesn't give any errors, however when the userform shows up it doesn't display the entities I have added to the combobox previously. That is, when I click on the combobox, it doesn't show any options, only one blank row, as if no items were added to it. Here is the code I'm using: Private Sub UserForm_Initialize() ComboBox1.AddItem "xxx" ComboBox1.AddItem "yyy" ComboBox1.AddItem "zzz" End Sub I am using the

email from Excel using Gmail

流过昼夜 提交于 2020-01-11 07:03:31
问题 I'm trying to have an email auto generate after a workbook is saved. I don't want to send the workbook in the email, just an email notification to a list of people to say that it has a new entry so they actually have to open it and respond (if I could put a link to the location of the spreadsheet that would work). Also the workbook is "shared" so multiple people can edit it at once, so I don't think it will remain as "shared" and continue to update if it is downloaded from an email. About 25

Sending email from excel automatically based on date

依然范特西╮ 提交于 2020-01-11 06:30:32
问题 I have an excel sheet with dated scheduling information. I would like to send daily updates on how many calls and how many appointments have been scheduled every day. The spreadsheet looks as follows: Date Scheduled Called Notes 07/06/2015 0 5 None 07/07/2015 5 12 None 07/08/2015 2 10 None I am trying to write a program that, say on 7/06/2015, an email will be generated with that days scheduled, calls, and notes in the body and automatically sent. Is this possible? 回答1: Here's what I think

VBA Run-time error '9': Subscript out of range; trying to activate another workbook

允我心安 提交于 2020-01-11 06:18:29
问题 I'm trying to create a VBA in Excel 2010 that takes info from another spreadsheet that I'm not allowed to alter and bring it over to the spreadsheet with my macro built in. Here's my code: Sub BringUpWorkbook() Workbooks("RITE 1624.xls").Activate End Sub I have several VBA books, have visited dozens of sites on the Internet, including those here at stackoverflow.com, and cannot find a reason why I'm receiving the run-time error. The workbook is already open, I've tried adding everything