Macros and VBA
6525 TopicsUsing mode with several criteria
Hello everyone! I'm currently treating some data before I send it to do some machine learning. I have the following data: id Ano mês data_inversa dia_semana horario uf br km municipio causa_acidente tipo_acidente classificacao_acidente fase_dia sentido_via condicao_metereologica tipo_pista tracado_via uso_solo ano pessoas mortos feridos_leves feridos_graves ilesos ignorados feridos veiculos And I created a new table to summarize this data for months instead of accidents, here are the columns: BR KM Ano Mês Clima (Moda) Tipo Pista Acidentes Veículos Ilesos Feridos Leves Feridos Graves Mortes Causa (Moda) Risco What I want to do is calculate the mode of condicao_metereologica for each combination of BR, KM, Ano and Mês. But I can't wrap my head around on how I could do this. Any help is appreciated! Let me know if I made anything not as clear as it is in my head xD39Views0likes1CommentTRES URGENT
Bonjour Le clic droit de la souris ne fonctionne plus sous Excel. Qui peut m’aider à le réparer ? MerciSolved3.2KViews0likes7CommentsExcel Tools for Network & Windows
Excel Tools for Network & Windows Some time ago I already shared an earlier version of this project. Since then, I have added several new features. These tools are based on functionalities that already exist in Windows and its associated software. I have consolidated them into a single Excel-based interface, allowing all tools to be executed directly from Excel. The files are free for private use. For business or enterprise environments, a more comprehensive toolbox can be developed, enabling direct support, repair, management, monitoring, and control of users and systems. Everything can be customized according to specific requirements — the scope depends solely on the desired functionality, time investment, and budget. I appreciate any positive feedback, suggestions, or constructive tips. If this project is not of interest to you, please feel free to ignore it. Thank you, and I wish everyone happy holidays.56Views1like2CommentsFinding time duration between a start date & time with end date & time
Hi all! I'm looking for any formula or power query to calculate a total time duration within a day, given the start date, start time, end date, end time. Most of the dates will equal the same but there are some with the end date being the next day. I'd like to be able to exclude any overlaps as well. Currently, I have a large embedded IF formula: =IF(AND($G4=$O4,$H4<$H5,$P4>=$H5,$P4<$P5,$H4<$H3),$P4-$H4,IF(AND($G4=$O4,$G4>$G3,$H4<$H3,$P4<$P3,$H4<$P3,$P4<$P5),$P4-$H4,IF(AND($G4=$O4,$H4>$H3,$H4>=$P3,$P4>$P3),$P4-$H4,IF(AND($G4=$O4,$H4=$P4),0,IF(AND($G4=$O4,$H4<$P3,$P4<=$P3),0,IF(AND($G4<$O4,$H4<$P3,$P4>$H4),($P4+1)-$P3,IF(AND($G4=$O4,$O4<$G5,$O4<$O5,$H4<$P3,$P4>$P3),$P4-$P3,IF(AND($G4=$O4,$G4>$G3,$H4>$H3,$P4>$P3,$H4>$P3),$P4-$H4,IF(AND($G4=$O4,$G4<$O5,$P4>$P3,$P4>$H5,$H4>$H3,$H4<$H5),0,IF(AND($G4=$O4,$O4=$G5,$H4<$P3,$P4>$H5,$P4>$P3,$P4>$P5,$P2>$P3),$P4-$P2,IF(AND($G4=$O4,$H4<$P3,$P4>$P3,$P4>$P5),$P4-$P3,IF(AND($G4=$O4,$H4<$P3,$P4>$P3,$H4<$H5,$P4<$P5),$P4-$P3,IF(AND($G4=$O4,$H4<$H5,$H4<$P3,$P4>$P3,$P4>$P5),$P4-$P3,IF(AND($G4=$O4,$O4=$G5,$H4<$P3,$P4>$H5,$P4>$P3),$P4-$P2,IF(AND(ISBLANK($O4),ISBLANK($P4)),0,IF(AND($G4<$O4,$H4<$P3,$P4<$H4),($P4+1)-$P3)))))))))))))))) This seems to work for the most part but there are a few that I just can't get. I also pulled up my query and started to enter in the time durations manually and it couldnt come up with anything automatic for me. There must be an easier way for me to do this other than trying to create an IF formula for each answer that turns up incorrect. I have a screen shot below.183Views0likes4CommentsInitializing TextBoxes within a UserForm
My spreadsheet contains a macro which utilizes two UserForms, each containing several TextBoxes. I want to initialize several TextBoxes in each Userform. One UserForm works and the other one does not, even though I have set the code up identically in each one. Here is what I have detected: When you step through the macro code (F8), when the first UserForm.Show statement is executed, the control skips to the first line of code for the UserForm and when the second UserForm.Show is executed, the control skips to the first TextBox on the Object. Here is a sample of the code I am using: Private Sub UserForm1() TextBox1.Value = "ABCDE" End Sub I have been writing macros like this for over 30 years, but this is the first time I have run into this situation. Any help here will be greatly appreciated. Al86Views0likes4CommentsLearning Macro Control Buttons
My goal is to embed two control buttons that pop up when a certain range of cells is selected. I have two columns (C:D) that have numeric entries for quantities of items. I want to be able to select a cell in this range and have two buttons appear next to active cell, one to add by an input value and one to subtract by an input value. I was able to create Form Control Buttons that can do the task but I can't figure out how to align them to the active cell and hide them if the active cell is outside of the desired range. Any suggestions? Do I need to use ActiveX buttons instead of Form Control?125Views1like1CommentTrying to insert Pivot Table
I recorded a new macro, using the tab View Macros-Record Macro, which resulted in the following VBA code: Sub CreatePivotTable() Sheets("Year Data").Select Range("A3:F24").Select ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _ "Year Data!R3C1:R24C6", Version:=xlPivotTableVersion14).CreatePivotTable _ TableDestination:="Yearly Summary!R3C1", TableName:="PivotTable3", _ DefaultVersion:=xlPivotTableVersion14 Sheets("Yearly Summary").Select Cells(3, 1).Select End Sub The recording did exactly as I wanted, taking the data from the "Year Data" WS and adding the new pivot table to the "Yearly Summary" WS. As a test of the macro, I deleted the initial pivot table that was created on the "Yearly Summary" WS. The problem I have now, when I attempt to run this macro again it constantly fails on the 4th line of the macro with Run-time error '5': Invalid procedure call or argument. ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _ "Year Data!R3C1:R24C6", Version:=xlPivotTableVersion14).CreatePivotTable _ TableDestination:="Yearly Summary!R3C1", TableName:="PivotTable3", _ DefaultVersion:=xlPivotTableVersion14 I cannot figure out why it works when I am recording the macro but fails when I try to run it alone. Help is greatly appreciated.Solved118Views0likes2CommentsDate of Last Modified for a Cell
Good day, all. I am inquiring if there is an excel function that would give me a date (and time) that an individual cell was last modified. For example: cell A2 has an entry of $2.55 and I'd like cell A3 to read "12/5/22 at 10am". a week later I change the $2.55 to $3.00....I'd like the A3 cell to read "12/12/22 at 10:30am". I've seen some VBA solutions but wondering if there is a simple excel formula to accomplish this?278KViews4likes82Comments