vba

Error handling with VBA compiling?

China☆狼群 提交于 2021-02-11 13:41:22
问题 How easy would it be for someone with only decent programming experience to add error handling for compiling? I have an Excel-VBA program that on some computers fails to locate the references, so I made a common folder and placed the .dll files there. Is there a way I can automate this error handling process? It is a compile error for "cannot find library" so I imagine I cannot do this with VBA. Is this easily doable? Thoughts? I did not attach code because there is nothing relevant to show.

VBA Run Macro and Screen Tip (or Tool Tip) From Shape. I cannot get the code I found to work

不问归期 提交于 2021-02-11 13:38:41
问题 I am using custom buttons (shapes) as buttons and I would like to use this code that I found but I cant get it to work correctly and I dont know why. The goal is to add a screentip to the shape as well as a macro. Normally this doesnt work. Only one or the other will work but not both. --- Please do not ask me to insert Activex Controls. I am aware Mouse move events. I did try that way and it works but it is very glitchy.--- The attached method would be perfect if anyone can help me

How to print values into next empty row cells?

笑着哭i 提交于 2021-02-11 13:37:57
问题 I have designed a VBA form to collect data from the user. However, I want to allow the user to fill the form multiple times and each time prints the filled out data into appropriate cells in the Excel sheet, so I want the VBA program to look for the next empty cell in the sheet without having the user to look manually and select it. Cells(lastRow, 1) = emplName Cells(lastRow, 2) = depTxt Cells(lastRow, 3) = emplNo Cells(lastRow, 4) = mngrName Cells(lastRow, 5) = ComboBox1.Value Here for

Continue procedure if CommandButton is clicked

与世无争的帅哥 提交于 2021-02-11 13:32:58
问题 So far I have used the below VBA in order to continue with a procedure if the user clicked ok in the MsgBox : Sub Button_Message_Box() Answer = MsgBox("Do you want to continue the procedure?", vbOK) If Answer = vbOK Then Sheet1.Range("A1").Value = 1 Else End If End Sub Now I want to achieve the exact same result using CommandButton1 in UserForm1 . Therefore I tried to go with this: (1) VBA in UserForm1 : Private Sub CommandButton1_Click() Unload Me End Sub (2) VBA in Modul1 : Sub Button

VBA Filter Partial String Containing Date

僤鯓⒐⒋嵵緔 提交于 2021-02-11 13:32:47
问题 I need to filter Col A based on a PARTIAL STRING. The user needs to be able to filter for YEAR only ... or YEAR & MONTH ... or YEAR & MONTH & DAY YEAR ONLY : 20 YEAR & MONTH : 2002 YEAR & MONTH & DAY : 200206 The following will filter the year or the year & month .... it fails to filter for year / month / day. Thank you for looking. Sub FiltDate() Dim strName As String Dim range_to_filter As Range On Error Resume Next Set range_to_filter = Range("A2:A500000") 'Sheet4. Dim ret As String Dim

Fast way to query listobject vba

坚强是说给别人听的谎言 提交于 2021-02-11 13:32:09
问题 I use excel 2016 and need to get a value from list object. There are several columns. For example three, and I need to get the value in column1 where column2=smth, column3=smth. How can I do this fast? 回答1: If you want SQL syntax and speed in VBA then you need to use the ADO DB connector. In my experience it was 4x faster than using native Excel functions to find the data. It's a lengthy topic that requires you read multiple articles. Much more information than should fit in to one SO post.

List an MS Access form's controls with their events

只谈情不闲聊 提交于 2021-02-11 13:28:56
问题 I have a humongous Access form with hundreds of controls, all with some events. One of them is throwing an error crying about "Validation or After Update event". No control name, nothing more to go by. So I figured I'd list all the forms with all their validation rules and all their events (not all of them are "[Event procedure]", some are custom function calls). Is there any way to get a list of a control's events? My code so far: Sub ListAllControlsAndTheirEvents(FormToCheck As Form) Dim

How to search 2 values on another Sheet and then based on that return a specific cell from the same row as them back on the 1st Sheet?

我只是一个虾纸丫 提交于 2021-02-11 13:24:55
问题 I was thinking of a double VBA VLOOKUP or a double conditional If for that 2 cells and return another cell from the specific row back on Sheet1. Basically a double VBA VLOOKUP or a double conditional IF when the strings were found I'd be going with the VLOOKUP in VBA , sort of look for A2 and D2 from Sheet 1 in Sheet 2 Range A1:A999 and D2:D999 and if the results match output C cell from the same row back on C2 in Sheet 1 But not sure how to proceed further. Any advice would be more than

Making a UTF-8 call from VBA

落花浮王杯 提交于 2021-02-11 13:23:29
问题 I'm trying to make calls to openstreetmap (specifically to https://nominatim.openstreetmap.org/search?amenity=charging_station&format=json&q=Elly-Beinhorn-Ring+2,12529+Schönefeld ) and from any webbrowser it works fine. When calling via Excel VBA is complains that the string is not UTF-8. I haven't used fiddler yet but to me it is clear that srequest should be in UTF-8 format. I found another solution to convert the url to ascii but I'd prefer to have it in utf-8 here's some sample code which

Select referenced range from non-active table via VBA in Excel

混江龙づ霸主 提交于 2021-02-11 13:05:53
问题 Given a certain range rngRange e.g. set rngRange = Workbooks(2).Worksheets(5).Range("C4:P49") If I use rngRange.select it will throw an error message if the table containing the range is not the active window/workbook/table (e.g. by wbWorkbook.Activate and wsWorsheet.Activate ). Using rngRange.Activate by itself doesn't work (throws an error), probable a simple problem. But somehow I'm blind today. Is it possible to "activate" the range directly without activating the workbook/worksheet first