excel-vba

How to trigger VBA code after adding a comment?

为君一笑 提交于 2020-01-25 08:46:06
问题 Say if you add a comment to a cell which includes the word "today", then we would like a VBA code to be tiggered to replace the "today" with today's date in that comment. But the problem here is that I could not find an event (or any other way) to know when a comment has been added, or to which cell (range object). Any ideas? My current stupid solution is to add VBA code inside Worksheet_SelectionChange event (it's a shame that I could not get the old location before the selection change),

Show a form on all worksheets in an Excel file

别等时光非礼了梦想. 提交于 2020-01-25 07:59:24
问题 I am writing a little generator script (using Excel VBA) to generate a bunch of source code, given various input from users. Currently I have one 'generator control' worksheet that provides access to the generation scripting tools. Here there is a button that pops up a little form with various generation options. Each portion of source code also gets its own worksheet for generation purposes. So, I essentially have one worksheet for generation commands and perhaps 10-20 that are for source

Error 13 - Type mismatch - Index Match

岁酱吖の 提交于 2020-01-25 07:50:07
问题 Getting the above error on the Index/Match. Will try and keep this short and sweet but I am a VBA noob. Everything that is called has data in. One thing I noticed was that RefCol (a range of numbers) has leading and trailing whitespace when I do a Debug Print. However when I tested the length of the value it returned the correct values. I can't understand what is breaking it, I did an index match in the workbook itself and it works perfectly. Private Sub Ref_Change() Dim ws As Worksheet Dim

Triggering the same Event Handler for multiple combo boxes

喜你入骨 提交于 2020-01-25 06:18:21
问题 IS there a way I can assign the same Onchange Event Handler to more than one Activex ComboBoxes rather than reproducing the Handler for each ComboBox like CmbBox1_change(), CmbBox2_change(), all which does te same stuff When using Form Controls, I could assign the same macro to several Combo Boxes 来源: https://stackoverflow.com/questions/13461991/triggering-the-same-event-handler-for-multiple-combo-boxes

VBA wildcards or partial matches

会有一股神秘感。 提交于 2020-01-25 05:57:38
问题 My code below looks through a list of keywords in column 37, in rows 5 to 17, in a different sheet called "Weights". For columns that do not contain these keywords, delete them. My problem is that it is looking for exact matches, so I need to place some wildcards or adjust the below to include partial matches. For example, if a keyword is "Open", then the column containing "Open & closed" would be deleted, which is not what I want. How is best to go about this? Sub DeleteUneededColumn() Dim

CreateObject(“Scripting.FileSystemObject”) doesn't work under Excel for Mac [duplicate]

末鹿安然 提交于 2020-01-25 05:56:25
问题 This question already has answers here : How can I install/use “Scripting.FileSystemObject” in Excel 2010 for MAC? (4 answers) Closed 5 years ago . I have a piece of VBA code which is used to get subfolders given a path, it works well under Excel for Windows : Function GetSubFolders(RootPath As String) Dim fso As Object Dim fld As Object Dim sf As Object Dim myArr Set fso = CreateObject("Scripting.FileSystemObject") Set fld = fso.GetFolder(RootPath) For Each sf In fld.SUBFOLDERS Counter =

VBA wildcards or partial matches

筅森魡賤 提交于 2020-01-25 05:56:08
问题 My code below looks through a list of keywords in column 37, in rows 5 to 17, in a different sheet called "Weights". For columns that do not contain these keywords, delete them. My problem is that it is looking for exact matches, so I need to place some wildcards or adjust the below to include partial matches. For example, if a keyword is "Open", then the column containing "Open & closed" would be deleted, which is not what I want. How is best to go about this? Sub DeleteUneededColumn() Dim

Pair Column A & B, get the matching results in C and the difference in D

三世轮回 提交于 2020-01-25 05:44:26
问题 I have columns "Manifesto A" and "Manifesto B" (with its correspondent volumes) that I get from my SQL Server 2008 DB. A has aprox. 1000 lines and B (and Volumes C) around 800, so it's almost impossible to compare they by hand. Column "Manifesto C" must have the results of the A>B matching and pairing, and add blank cells where there is no match, as this image example shows . I've tried this , this , and some SQL CASE WHEN . I don't know VBA , but I'll copy paste anything if you say so. Can

Get Excel macros names with descriptions

心已入冬 提交于 2020-01-25 05:16:44
问题 I have found many ways for getting macro names from Excel using automation (example). They are mostly the same and neither can 1) retrieve macro descriptions (each recorded macro can be decorated with a description using Excel UI) or 2) filter out ordinary VBA functions (there are Excel recorded macros and there are funcs/macros that you an write yourself). It seems as if Excel is keeping descriptions as comments in the source code but also in some private place too. If one deletes code

How to find a specific cell value in separate worksheet?

不羁岁月 提交于 2020-01-25 04:57:12
问题 I have a piece of code that searches a range in the current worksheet for a specific cell value and then does an action on that column. The macro is launched by a form control button on the same page. I need to move the form control button to a different worksheet but I am not sure how to udpate my code to only search in sheet1 and not in the sheet where the button in. Below is my code that works when using the button on the same worksheet as the data. I just need it to look at sheet1 instead