macros and vba
6542 TopicsVBA Code "Next" button. Should be so simple...
I have the following codes in the click event for a "next" and "prev" buttons on my userform. The prev button works fine, the next button will not advance to the next record in my table, and instead gives me the "Last record" message box (regardless of the active row). If I remove the If...Then loop it works fine. WHY is it looping to the "last record" msgbox when it is clearly not on the last record?? Any ideas greatly appreciated Dim LastFind As Range Dim CurrentRow As Long Private Sub CommandButton6_Click() If CurrentRow < LastRow Then CurrentRow = CurrentRow + 1 LoadRecord CurrentRow Else MsgBox "This is the last record." End If End Sub Private Sub CommandButton7_Click() If CurrentRow > 5 Then CurrentRow = CurrentRow - 1 LoadRecord CurrentRow Else MsgBox "This is the first record." End If End Sub104Views0likes2CommentsHide rows based on Drop-down box selection
Hello, I have a drop-down box with different selections. One of which is "VPN to VPN Cloud-Based". If this is selected then I want to hide rows 36 through 239. Doing something wrong in my code, as it isn't doing anything when "VPN to VPN Cloud-Based" is select. Any ideas what I need to change? Attaching screenshot of the form and the VBA. Thanks.Solved81Views0likes3CommentsHelp needed with IF and COUNTIFS Formulas
Is anyone able to advise the following formula: =COUNTIFS($B$5:$B$15,$R$4,$C5:$C15,"<=" & V3,$D5:$D15, ">" & V3)-COUNTIFS($B$5:$B$15,"="&$R$4,$G5:$G15,"<=" & V3,$H5:$H15, ">" & V3)-COUNTIFS($B$5:$B$15,"="&$R$4,$K5:$K15,"<=" & V3,$L5:$L15, ">" & V3)-COUNTIFS($B$5:$B$15,"="&$R$4,$O5:$O15,"<=" & V3,$P5:$P15, ">" & V3) Is there a way to simplify this? Is there a way to make this more accurate? Cells in column G & H, I & J, O & P are using the following format: =IF(C6="","",C6+E6) Cells in U4:CC4 are using the following format: =COUNTIFS($B$5:$B$15,$R$4,$C5:$C15,"<=" & U3,$D5:$D15, ">" & U3)-COUNTIFS($B$5:$B$15,"="&$R$4,$G5:$G15,"<=" & U3,$H5:$H15, ">" & U3)-COUNTIFS($B$5:$B$15,"="&$R$4,$K5:$K15,"<=" & U3,$L5:$L15, ">" & U3)-COUNTIFS($B$5:$B$15,"="&$R$4,$O5:$O15,"<=" & U3,$P5:$P15, ">" & U3) Cells in U5:CC15 are using the following format: =IF(U$4>=$T5,1,"") My issue is is when I put in the three break times, the mid break comes out at a shorter time. My other issue is is that when I put in the times in row 5,6and 11, the data is coming up as a combined data in rows 5, 6 and seven on the page two. Just for reference, "page two" is the same spreadsheet. What I need to happen is that I enter in the shift start time and finish time. This then populates through to Break 1, 2 and 3. The Time entry is the time the break starts. ie: 1 hour after start of shift, 1 hour after coming back from break, etc. The break entry is the duration of the break taken. ie: 30 minutes. Once all the info is put in, the relevant "Time Block" on "Page 2" shows a 1. What is happening at the moment is that when I enter all the time data, the time blocks are not populating correctly in accordance to the entry. Basically, If I have numerous people on shiftI need the time blocks to show where I have shortfalls in shift cover and not having too many people on break at the same time. IE: Link to Live Copy: https://www.dropbox.com/scl/fi/eur1j526htu1j8a4d4290/Staff-Breaks.xlsx?rlkey=r4tm9xts4tonofpa2th2cusfw&st=nueyk0d7&dl=0 Any ideas would be greatly appreciated.186Views0likes4CommentsHow do I save an Excel Add-in (XLAM) file?
We had a new(er) version of Excel shoved on us and the result it it doens't do this, so we're sort of in a bad place. How do I save the add-in? We were probably on an old-ish version because it was stable and upgrades tend to break us - as they have here. I'm wondering how I save an add-in now. Right now our workflow is completely broken. When I go to File--> Save there is no xlam file type available now. I can still load an old xlam but I can't create a new one.Solved186Views0likes4CommentsExcel VBA – Target a specific named table when multiple ListObjects exist on each worksheet
My workbook has 12 sheets each having the name of a month. Each sheet contains a table named LotSize?? where ?? = number of the respective month as given below. Sheet name-Table name: January-LotSize01, February-LotSize02,...., December-LotSize12. Each of these tables have two columns named SCRIP and LotSize. I want a simple VBA code for following: 1] Clear the content of LotSize column of each such table from all 12 sheets. 2] Add text A, B, C, D, E in the cells of column SCRIP of each such table in all 12 sheets. I will later replace A, B, C, ...etc. with the actual scrip names as per requirement. Sub UpdateTables() Dim monthNames As Variant: monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") Dim vals As Variant: vals = Array("A", "B", "C", "D", "E") Dim ws As Worksheet Dim tbl As ListObject Dim lr As ListRow Dim i As Long Dim j As Integer For i = LBound(monthNames) To UBound(monthNames) Set ws = ThisWorkbook.Worksheets(monthNames(i)) If Not ws Is Nothing Then If ws.ListObjects.Count > 0 Then Set tbl = ws.ListObjects(1) With tbl If Not .DataBodyRange Is Nothing Then .DataBodyRange.Delete For j = 1 To 5 Set lr = .ListRows.Add lr.Range(tbl.ListColumns("SCRIP").Index) = vals(j - 1) Next j End With End If End If Set ws = Nothing Set tbl = Nothing Set lr = Nothing Next i End Sub Above code works only if each sheet has only one such table but I am having three different tables on each sheet with LotSize?? (?? = Month number) being one of them. How can we modify given code to incorporate this change so that the code operates on the desired table to achieve the stated objectives?Solved140Views0likes5CommentsI need help with userform create list of teams no repeated
I have a userform for the NFL playoffs. 14 combo boxes for wild card & Divisional only. I want to create a search with no repeat, and after I pick team, should not the list should not be repeated. Dark red is for AFC TEAMS and dark blue is for NFC TEAMS. I have listed teams on the teams info worksheet. I need help getting this working39Views0likes0CommentsCannot delete a macro
Windows 10 desktop computer, Excel I recorded a macro, seems to have an error. Want to Delete it and try again. When I go into Macros, I see it listed and highlighted (it is the only one), try to click Delete, but get message : "Cannot edit a macro on a hidden workbook. Unhide the workbook using the Unhide command" Don't know what this means. I don't know of any hidden workbooks, never did anything to hide any workbook. Help for "unhide" says go to Home-->(Cells) Format-->Visibility-->Hide&Unhide, but when I go there, the entry for Unhide Sheet is grayed out. so cannot do that anyway. I just want to delete the macro I recorded before and try to record it again to get rid of whatever error it contains. This is a macro I intended to use in any Excel workbook and is listed as PERSONAL.XLSB!(name) and below the list of Macro names there is a box Macros in: All Open Workbooks It is the only macro listed, there are no others.5.6KViews0likes12CommentsChange in return of AVERAGE function - Mac Excel
I was puzzled that a spreadsheet I use daily generated an error today that had not existed in earlier versions. Attempts to confirm the validity of the spreadsheet functions by running prior versions that had previously run error free resulted in the same error. Eventually, it seems that the operation of the AVERAGE function has been changed in an Excel program update that was installed yesterday. Previously, if an AVERAGE function addressed a range of empty cells, it would return a zero value. Now it is returning the error #DIV/0! This is strange because the AVERAGE function will now return zero if the addressed range contains zeros rather than just being empty. Not sure if Microsoft intended this change or if the change might also apply to other functions. In muy case, I'm able to change my spreadsheet to provide for this but it would have been nice to have some warning.Solved192Views0likes3CommentsCannot add a worksheet to my Excel spreadsheet
I haver all of a sudden lost the ability to add worksheets to my spreadsheet program. I am using macros that both protect and unprotect the sheets that are currently there, but I want to add another sheet, and the plus sign at the bottom is grayed out as well as the 'Insert Line' line when you do Home/Insert. I have looked and I cannot find the setting that controls the addition of worksheets. Any suggestions???134Views0likes6Comments