Macros and VBA
6515 TopicsVBA code to allow dropdown box multiple selection
Hi all, Is there an option to allow multiple selections of a dropdown box within excel? the dropdown would be in column V (v2 downwards, and the list is in tab “Entities” from a2 down to a6. the codes I have tried from online either didn’t allow me to remove a selected item, or when I did remove it and try to select others I ended up with “floating” commas. Ie it went from “apple, pear, banana” to “,pear ,” and I couldn’t remove the commas. thanks29Views0likes1CommentTouch screen does not work for graphic in top left
https://1drv.ms/x/s!AnFi6uGE1rekjWGpZ8gIIOp89wsQ?e=2R6PaT in the workbook i have a blue graphic button with a simple macros. select a cell. then click the button and "1" goes into the active cell. but if i do touch screen, the touchscreen option for the button does not work when the button is in the highlighted yellow area (highlighted for reference). anyone know how to resolve for touchscreen?2.3KViews0likes6CommentsCan I control what is displayed in a FileDialog
Hello Excelers, Hope you are all doing well. Is there an option to limit the files displayed when you use something like: With Application.FileDialog(msoFileDialogFilePciker) .InitialFileName = "Book1" .InitialView = msoFileDialogViewDetails .Filters.Add "Excel Files, *.xls*" .Title = "Choose a File" (A way to limit files with a date range of say 7 days ago till yesterday .Show End With I want to limit the files displayed by a date of 7 days ago to yesterday. I know I can use the DateLastModified of a file but the question is how to incorporate this with the msoFileDialogFilePciker. Thanks in Advance! GiGi38Views0likes1CommentExcel Security Warning:
Hello Everyone, I am having one strange issue. I am working on a excel which has few Power Queries and around 10 sheets. I have not created any macros. But in VBA Editor there are two VBA Projects. But they do not have any macros in it. Now the issue is, every time I open this excel file, I have been greeted with the "Security Warning: External Data connections have been disabled". and I need to press the "Enable Content" button every time. I have tried saving the file as .xlxs (from .xlam) but it didn't solve the issue completely, it does not throw error in some machines still and I have also tried to remove these two projects which has but no luck. Can someone let me know if this is a known issue? What are possible ways I can remove this warning (only for this file) as technically I am not using any macros. Any help would be highly appreciated. Let me know if you need more details. Thanking you.35Views0likes2CommentsAdd VBA Code to an Option button dynamically
Hello Excelers, I hope you are doing well. I am back for some more help and here is what I am trying to accomplish: I have some code that would add x Option Buttons to a User form. x is Unknown but usually less than 15 but maybe more at times. I need to assign a macro that would return the newly created Option Button's Caption. In a Module I have: Dim objOptBtn as MSForms.OptionButton In a For i = 1 to x loop I have: Set objOptBtn = uFrmChoice.controls.add("Forms.OptionButton.1","objOptBtn" & i,true) With objOptBtn .Caption = i .snglTextWidth = Len(objOptBtn.caption) .width = snglTextWidth + 18 .Left = 10 .Top = TopLevel + 10 .Width = 400 .Height = 18 End With I remember there was an .OnAction "MacroNameYouWantToRunWhenOptionButtonIsClicked" But I do not see it in the Intelisense???? How can I assign code to run once the user clicks on a Option Button on the UserForm and return the Caption of that Option button? I am trying to ask the user to choose ONE option from a set of unknown options.18Views0likes0CommentsSearch for a date in a row does not work in VBA with ".find" when column is too narrow
I have a row with dates (row 3) and a cell with a date (C7) I want to get the column where this date (C7) is in that row3 This is my code: Sub find_date() Dim datum As Date Dim zoekrij As String Dim cel As Range datum = Range("C7").Value zoekrij = "A3:Z3" Set cel = Range(zoekrij).Find(DateValue(datum), LookIn:=xlValues, LookAt:=xlWhole) If Not cel Is Nothing Then MsgBox ("Date found in column: " & cel.Column) Else MsgBox ("Date not found") End If End Sub This works when the row 3 is formatted as date and the column is wide enough, but when the column is too narrow and shows "####" the date is not found. I also tried to use Clng(datum) and formatted the row as numeric, but with the same result (works only when column is wide enough)35Views0likes1CommentExcel for Mac - Run-time error '1004': Method 'Name' of object 'Addin' failed
Dears, Whenever I open any Excel File (existing or blank), I get the following error message: "Visual Basic for Applications Run-time error '1004': Method 'Name' of object 'Addin' failed" Note: I don't have any VBA code in the file - again, this message also appears when opening a blank/new/empty file. I thought it could be related to one of the Add-ins that I had installed, but even after removing all of them, the message still appears. Does anybody know what it means and how to fix it? I'm running Excel for Mac Version 16.91 (24111020) from Microsoft 365 in macOS Sequoia Version 15.1.1. Thanks in advance, AndreSolved1.2KViews2likes8CommentsPower query refresh using script
I am trying to automate the power query refresh using power automate. Change in a folder triggers multiple scripts. All the scripts seem to be working fine, but the final script to refresh the connections, to show updated query results in the various tabs is not working. function main(workbook: ExcelScript.Workbook) { // Refresh all data connections workbook.refreshAllDataConnections(); } what might be different about this? thanks!45Views0likes2CommentsPower query refresh using script
I am trying to automate a power query refresh using power automate. The flow seems to be working fine, but the excel in itself isn't refreshing the output tables. The script I am using is this function main(workbook: ExcelScript.Workbook) { // Refresh all data connections workbook.refreshAllDataConnections(); } I can see the updated query in the query editor, but not in the output tabs within the excel.34Views0likes1CommentCleaning up data with Macros
Hello everyone! I am cleaning up a worksheet that I use frequently to track weekly expenses and spending. I just discovered Macros and I want to use them to clean up my worksheet. Using Macros, how can I create a button that clears entries that are 3 (or more) months old?59Views0likes2Comments