excel-vba


How to check for empty array in vba macro [duplicate]

百般思念 提交于 2020-01-18 04:55:23
问题 This question already has answers here : How do I determine if an array is initialized in VB6? (22 answers) Closed 5 months ago . I want to check for empty arrays. Google gave me varied solutions but nothing worked. Maybe I am not applying them correctly. Function GetBoiler(ByVal sFile As String) As String 'Email Signature Dim fso As Object Dim ts As Object Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2) GetBoiler = ts.ReadAll ts.Close

How to check for empty array in vba macro [duplicate]

北慕城南 提交于 2020-01-18 04:55:10
问题 This question already has answers here : How do I determine if an array is initialized in VB6? (22 answers) Closed 5 months ago . I want to check for empty arrays. Google gave me varied solutions but nothing worked. Maybe I am not applying them correctly. Function GetBoiler(ByVal sFile As String) As String 'Email Signature Dim fso As Object Dim ts As Object Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2) GetBoiler = ts.ReadAll ts.Close

Hide/Unhide cells with empty rows on Worksheet_Change

假如想象 提交于 2020-01-17 16:42:39
问题 I have two columns of data that is pulled into a worksheet from data on other sheets elsewhere in the workbook via a formula in each cell... The first column, Column A, has either a Yes, No or is blank from data that is pulled in via a formula from another sheet. The second column, Column B, also has data pulled in from elsewhere but every row has data in it. What I hope to do is hide any rows that does not have anything in column A. Any rows with data in column A should be visible. I'd like

VBA Macro running too fast

江枫思渺然 提交于 2020-01-17 16:39:27
问题 It's weird that I'm finding ways to slow down my macro. Apart from Doevents and other time delay techniques, which are basically a workaround, is there a way through which we can get around the asynchronous execution. As in, I want the VBA code to behave like this: start executing line 1>finish executing line 1>move to line 2; Forgive if I'm wrong but currently it seems to follow: Start executing line 1>without caring whether line 1 finished or not start executing line2 回答1: If you are

Macro for merging cells

我只是一个虾纸丫 提交于 2020-01-17 16:37:30
问题 I have an Excel file with Invoice number in Column B, ( B2:B14987 ), in Column C I have Item ID's, in Column D I have Sold Value, in Column E I have Invoice-Discount Value. I need a macro to merge the Invoice Discount value cells based on Invoice number column, invoice numbers are repeated as there are different item ID's in one invoice. For example: B1:B3 are the same invoice number, E1 is the common discount value for the invoices which are in B1:B3 , E2:E3 are blank cells. So I want E1:E3

Macro for merging cells

蓝咒 提交于 2020-01-17 16:37:10
问题 I have an Excel file with Invoice number in Column B, ( B2:B14987 ), in Column C I have Item ID's, in Column D I have Sold Value, in Column E I have Invoice-Discount Value. I need a macro to merge the Invoice Discount value cells based on Invoice number column, invoice numbers are repeated as there are different item ID's in one invoice. For example: B1:B3 are the same invoice number, E1 is the common discount value for the invoices which are in B1:B3 , E2:E3 are blank cells. So I want E1:E3

Excel VBA Workbook Update

跟風遠走 提交于 2020-01-17 16:35:14
问题 I currently have a workbook with a macro to update a range from an identical range on a master sheet. Right now, I simply use a macro to open the master workbook, copy the range from it and paste the values in the same range in the other workbook. Here is the code I am currently using: Sub GetDataFromClosedWorkbook() 'Created by XXXX 5/2/2014 Application.ScreenUpdating = False ' turn off the screen updating Dim wb As Workbook Set wb = Workbooks.Open("LOCATION OF FILE", True, True) ' open the

Pass VBA Variable into Access Query(Excel VBA)

不想你离开。 提交于 2020-01-17 14:59:28
问题 Im new at trying to construct queries out of vba. I am trying to figure out how to pass a variable inside the VBA syntax. Mind showing me where im dumb? I tried this below but there's an automation error that pops up. Ive noticed from playing aroudn that automation errors come up when youve just got syntax wrong, so hopefully its something small? Any help is greatly appreciated Sub GetDataFromAccess() Dim cmd As New ADODB.Command, rs As ADODB.Recordset Dim recordNum As Integer recordNum = 7

Pass VBA Variable into Access Query(Excel VBA)

好久不见. 提交于 2020-01-17 14:58:12
问题 Im new at trying to construct queries out of vba. I am trying to figure out how to pass a variable inside the VBA syntax. Mind showing me where im dumb? I tried this below but there's an automation error that pops up. Ive noticed from playing aroudn that automation errors come up when youve just got syntax wrong, so hopefully its something small? Any help is greatly appreciated Sub GetDataFromAccess() Dim cmd As New ADODB.Command, rs As ADODB.Recordset Dim recordNum As Integer recordNum = 7

Macro to copy to next blank row on another sheet

…衆ロ難τιáo~ 提交于 2020-01-17 14:56:27
问题 I'm using this macro to copy from one sheet to another based on text in one cell, but it overwrites the data every time I run the macro. Is there any way to change the macro so that any data it pastes is in the next blank row? Thanks :) Sub CopyYes() Dim c As Range Dim j As Integer Dim Source As Worksheet Dim Target As Worksheet ' Change worksheet designations as needed Set Source = ActiveWorkbook.Worksheets("Main Data") Set Target = ActiveWorkbook.Worksheets("Cheque Data") j = 1 ' Start

工具导航Map