excel-vba

Excel VBA Range object Error in Looping Through Worksheet

雨燕双飞 提交于 2020-01-03 04:28:05
问题 I am trying to loop through different sheets in my workbook. I have tried searching through stackoverflow but still stuck with the error. The error showed "Method 'Range' of object'_Worksheet' failed. The purpose of this code is to standardise all formats in the worksheets. Sub formatting() Dim ws as Worksheet Dim lastRow as long, lastColumn as long lastRow = Range("A" & Rows.Count).End(xlUp).Row lastColumn = (Cells(1, Columns.Count).End(xlToLeft).Column) For each ws in Activeworkbook

Reuse Excel VBA without importing it

狂风中的少年 提交于 2020-01-03 04:27:47
问题 I created a new macro by recoding my actions. It is used to delete columns from an excel file. If I have to run this macro on excel file that I download from the web, I have to import the macro in visual basic and then run it. Can I somehow make this macro available to excel so I can run it to all the excel files that I download from a site, without importing the macro in visual basic first? 回答1: You can save macros to your personal workbook: http://excelhints.com/2010/11/29/how-to-use-your

Reuse Excel VBA without importing it

两盒软妹~` 提交于 2020-01-03 04:27:06
问题 I created a new macro by recoding my actions. It is used to delete columns from an excel file. If I have to run this macro on excel file that I download from the web, I have to import the macro in visual basic and then run it. Can I somehow make this macro available to excel so I can run it to all the excel files that I download from a site, without importing the macro in visual basic first? 回答1: You can save macros to your personal workbook: http://excelhints.com/2010/11/29/how-to-use-your

Save export from range in excel to Word and save as name in Cell A1

独自空忆成欢 提交于 2020-01-03 04:25:15
问题 I am now exporting a range of cells into Word using a macro in excel. There are some changes though as I need it to instead copy this to a NEW Word document and not an existing one that is in the script? My range that is selected is made up of various Vlookup results. Also, if possible, I want to get the file name to be whatever is in A1. Sub Export_Table_Data_Word() 'Name of the existing Word document Const stWordDocument As String = "Table Report.docx" 'Word objects. Dim wdApp As Word

Close UserForm from Module

情到浓时终转凉″ 提交于 2020-01-03 04:23:44
问题 I am trying to Close a User Form from a module, but it's not working. Here is what I have tried Sub UpdateSheetButton() Dim subStr1 As String Dim subSrrt2() As String Dim tmp As Integer Dim pos As Integer Dim Form As WaitMessage Set Form = New WaitMessage With Form .Message_wait = Module2.Label_PleaseWait .Show End With For Each Cell In ActiveSheet.UsedRange.Cells subStr1 = RemoveTextBetween(Cell.formula, "'C:\", "\AddIns\XL-EZ Addin.xla'!") tmp = Len(subStr1) < 1 If tmp >= 0 Then Cell

Excel VBA Scroll bar which shift sheet left or right

十年热恋 提交于 2020-01-03 04:19:12
问题 Request: VBA code for mini scroll bar which shift sheet left or right using VBA or ActiveX scroll bar? I have created a trainer skills matrix which has trainer names listed down the side (in cells 'B7' through 'B86') and Skill disciplines listed along the top (in cells E6 through 'AJ6'). Where the trainers name and a skill intersect I have a dropdown list stating ‘Y’ for has skill, ‘N’ does not skill and ‘n\a’. if the skill is not appropriate for that trainer. I have frozen the header rows

Variable number of arguments in ParamArray ArgList()

前提是你 提交于 2020-01-03 04:14:07
问题 If I want to pass a number of values for the ParamArray arglist via an array, how do I do it? From what I've read so far, on VBA, it appears that I need to explicitly list the values that I want to pass. But what if there are potentially different numbers of values to pass, so I do not know in advance how many I'll want to pass to the function? Is there not some way of using an array (a one-dimensional array) with a variable dimension? 回答1: There are several ways to achieve that: dimension

Protecting Excel Custom UI Ribbon

我的梦境 提交于 2020-01-03 04:07:09
问题 The purpose is to write a VBA to check to see if the custom Ribbon button label was changed. Upon Workbook_Open event, the vba will get the label value of a specific button of custom Ribbon and compared it with a hardcoded value in VBA. If they are not the same the vba would close the workbook. For instance, you can get the value of the label of built-in command with this MsgBox Application.CommandBars.GetLabelMso("PasteSpecialDialog") But how to get the value of the label of custom ribbon

Replacement of old modules with updated ones in PERSONAL.XLSB

二次信任 提交于 2020-01-03 03:56:04
问题 I have written a vba code in a workbook (with many modules) and I need to send the archive (such as Setup.XLSB) including the new code to other people at my work. After they open the Setup.XLSB and click an installer button in order to Call the install_new_modules_inside_personal() , it should replace old modules inside the PERSONAL.XLSB with the new ones. If the user has already his own modules in PERSONAL.XLSB, I don’t want them to be deleted. I just want my modules including the new code

VBA Sort DIR to transfer data in alphabetical order

只谈情不闲聊 提交于 2020-01-03 03:29:11
问题 I have written a macro below to copy and paste data from all workbooks within a user selected folder into a master document, however currently the macro selects the files in a random order. What I want to do is for it to select the files in alphabetical order, so the data in the master document is in the correct order... Help achieving this would be much appreciated, I am not precious about the method! Sub Import_Data() ' PURPOSE: To loop through all Excel files in a user specified folder and