excel-vba

Invalidate Ribbon Control Without Module-Level Variables

£可爱£侵袭症+ 提交于 2020-05-10 20:01:52
问题 I've developed an Excel add-in that includes a custom ribbon. I'd like to be able to invalidate (enable/disable) a control on the ribbon in certain situations, but every example I can find uses a module-level or global variable to store the ribbon object when the ribbon is first loaded. This seems like a good way to do it, but, as listed here, there are instances when variables can empty. So I'm wondering, is there a different way to achieve the result of enabling/disabling a control in an

Not able to create array from 1 cell range in VBA

梦想的初衷 提交于 2020-05-09 08:33:28
问题 I have code that reads ranges and converts them to arrays for processing. It unfortunately fails when the range only has one cell. To boil down the problem, consider the following ranges (r1, r2) with respectively 1 and 2 cells, that I want to convert to arrays a1 and a2, respectively: Sub ranges_to_arrays() Dim r1 As Range, r2 as Range Dim a1() As Variant, a2() as Variant Set r2 = Worksheets("test").Range("A1:A2") a2 = r2 ' Creates Variant(1 to 2, 1 to 1) Set r1 = Worksheets("test").Range(

Can I assign a function in an excel add-in to a button in the workbook?

为君一笑 提交于 2020-05-09 06:35:10
问题 I want to have a button in the sheet that you can press that will run part of the add in. Is this possible? 回答1: ok ill look into that. but is there a way to do so with a button in a sheet? – Jacxel 7 mins ago Yes you can. I am assuming that you have an Add-In called MyAddIn.xlam and you have a procedure called `Sample()' in the module of the Add-In. I am also assuming that the Add-In is installed. Replace the file MyAddIn.xlam with the relevant Add-In name and replace the procedure Sample

I am looking to combine multiple sheets into a single consolidated sheet

时光总嘲笑我的痴心妄想 提交于 2020-05-09 06:14:01
问题 Would like to create a Macro to loop through all of the sheets in the workbook and select all the data from each worksheet and then paste said data into a single consolidate table on the "Master" sheet. All sheets have the same column heading to Column "AB". Currently tried using this code but I have been unable to get anything to paste over onto the Master worksheet. Might be overthinking setting the range each tab. Just looking for a simple solution to copy all active data from each sheet

I am looking to combine multiple sheets into a single consolidated sheet

允我心安 提交于 2020-05-09 06:13:21
问题 Would like to create a Macro to loop through all of the sheets in the workbook and select all the data from each worksheet and then paste said data into a single consolidate table on the "Master" sheet. All sheets have the same column heading to Column "AB". Currently tried using this code but I have been unable to get anything to paste over onto the Master worksheet. Might be overthinking setting the range each tab. Just looking for a simple solution to copy all active data from each sheet

Add new lines in VBA email

本秂侑毒 提交于 2020-05-08 06:56:42
问题 I'm trying to send an email automatically through Excel, but the new line commands aren't working! I've tried <br/> , vbCrLf and vbNewLine .HTMLbody = "Hello" & vbNewLine & "Please find attached the above invoices and backup" & vbNewLine & _ "Any queries please let me know" & vbNewLine & "Regards" & vbNewLine & Signature It keeps just giving Hello Please find attached the above invoices and backup Any queries please let me know Regards as one line! 回答1: May be you can try this instead: Use

How Do I Populate a ComboBox With an Existing Array

允我心安 提交于 2020-05-01 18:21:11
问题 When I try to edit details of an existing item, my code fails to fill in the corresponding information for the last two items in the list. There is a combobox for selecting the item to edit, then a textbox for the item ID, as well as a textbox for the dates the item was ordered and when it was shipped, then two more comboboxes for selecting the shipping status and the online store it was purchased through. These fields are all auto-filled with the corresponding information for the item that

How Do I Populate a ComboBox With an Existing Array

孤者浪人 提交于 2020-05-01 18:20:27
问题 When I try to edit details of an existing item, my code fails to fill in the corresponding information for the last two items in the list. There is a combobox for selecting the item to edit, then a textbox for the item ID, as well as a textbox for the dates the item was ordered and when it was shipped, then two more comboboxes for selecting the shipping status and the online store it was purchased through. These fields are all auto-filled with the corresponding information for the item that

Run time error '1004': Copy method of worksheet class failed

て烟熏妆下的殇ゞ 提交于 2020-05-01 09:51:14
问题 I want to split workbook by worksheet name but if throws above error after splitting 5 sheets but i have 20 sheets in the workbook. I have used below code and the error happens at xWs.copy. Please help me fix the error in the code. Thanks in advance. Sub Splitbook() 'Updateby20140612 Dim xPath As String xPath = Application.ActiveWorkbook.Path Application.ScreenUpdating = False Application.DisplayAlerts = False For Each xWs In ThisWorkbook.Sheets xWs.Copy Application.ActiveWorkbook.SaveAs

Run time error '1004': Copy method of worksheet class failed

北城余情 提交于 2020-05-01 09:47:19
问题 I want to split workbook by worksheet name but if throws above error after splitting 5 sheets but i have 20 sheets in the workbook. I have used below code and the error happens at xWs.copy. Please help me fix the error in the code. Thanks in advance. Sub Splitbook() 'Updateby20140612 Dim xPath As String xPath = Application.ActiveWorkbook.Path Application.ScreenUpdating = False Application.DisplayAlerts = False For Each xWs In ThisWorkbook.Sheets xWs.Copy Application.ActiveWorkbook.SaveAs