-
WSCFDguru
AskWoody LoungerPerhaps you have non-numeric values in between the numbers? The formula I posted DOES sum the last 10 cells starting from the last non-blank cell upwards.
You are correct. The mistake that I’ve made was to insert a new row after I assigned the formula. That made A1 go to B1, and so it summed an empty cell.
-
WSCFDguru
AskWoody LoungerFor column A, you can use the following formula:
=SUM(OFFSET(A$1,MATCH(9.99999999999999E+307,A:A)-10,0,10,1))
For column F, change the references from A to F.
If you need to sum the last 15 cells instead of the last 10, change both occurrences of 10 to 15.Note: 9.99999999999999E+307 is the largest number you can enter in a cell.
Great. Thanks. I found that with this formula, it actually sums the last 9 numbers rather than 10, so I changed the ’10’ to ’11’.
-
WSCFDguru
AskWoody LoungerI have attached an example of what I currently have. The problem I have is that when I click on the N/A checkbox I get a message that I setup in the textbox event. How can I fix this so it will work properly?
-
WSCFDguru
AskWoody LoungerYou could use the Exit event to validate the contents. If they don’t match, pop up a message and set the Cancel argument to True.
Can you give me an example?
-
WSCFDguru
AskWoody LoungerIn the second example I should have had
Dim wsh As Worksheet
instead of
Dim wsh As Range
That did it. Thanks.
-
WSCFDguru
AskWoody LoungerThanks Hans. I now get a “Run-time error ’13’: Type mismatch” at this line:
With frmProperties
Do you know why?
-
WSCFDguru
AskWoody LoungerAny idea why I get a “Run-time error ‘1004’: Application-defined or Object-defined error” in this line of the module:
Sub ShowDialog()
With frmProperties ‘ <<< Error shows up here
.cmbType.RowSource = ""
.lstName.RowSource = ""
.lstFinish.RowSource = ""
.lstProperties_BOL.RowSource = ""
.lstProperties_EOL.RowSource = ""
.lstName.MultiSelect = fmMultiSelectMulti
.lstFinish.MultiSelect = fmMultiSelectMulti
.lstProperties_BOL.MultiSelect = fmMultiSelectExtended
.lstProperties_EOL.MultiSelect = fmMultiSelectExtended
End With' Assign material names to ComboBox
GetMaterialNames
' Show the UserForm
frmProperties.Show
End SubWhen I use the following code in the userform module?
Private Sub UserForm_Initialize()
' Worksheets("Properties Database").Activate
' Set rngAllMaterialTypes = ActiveWorkbook. _
Worksheets("Properties Database"). _
Range("A5", Range("A65536").End(xlUp)) ' <<<< WORKS when removing the two comment signsSet rngAllMaterialTypes = ActiveWorkbook. _
Worksheets("Properties Database"). _
Range("A5", Range("A65536").End(xlUp)) ' <<<< DOESN'T WORK -
WSCFDguru
AskWoody LoungerOne last question. As you can see from the attached figure, I get these dotted lines that disrupt the view in the listbox when I scroll from left to right, and back again. Any idea how I can avoid this from happening?
-
WSCFDguru
AskWoody LoungerIf you set the ColumnWidths property of the list boxto a large enough number, the list box will display a horizontal scroll bar.
It’s not easy, however, to make the ColumnWidths just large enough to fit the text, since you probably use a proportional font.Thanks Hans. Can you control the appearance of a horizontal scroll bar such that if the text fits within the current width of listbox then a scroll bar won’t show up, and if the full length of the text that appears within the listbox is beyond the width of the listbox then a horizontal scroll bar would appear? If so, how?
-
WSCFDguru
AskWoody LoungerRound is a function, so you must assign its return value to a variable:
Dim dblVal As Double
If IsNumeric(strABOL) Then dblVal = Round(strABOL, 2)(Please note that it is IsNumeric, not IsNumberic)
Great. Thanks Hans.
-
WSCFDguru
AskWoody LoungerYou’ve gone overboard with the Ranges. Change
Set rngMaterialName = Range(Range(Range(“A5”), Range(“A65536”).End(xlUp)))
to
Set rngMaterialName = Range(Range(“A5”), Range(“A65536”).End(xlUp))
and in lsType_Change, you’re missing an End If between Next rng and Next rngName (the indentation of the code is not correct there)
Thanks again Hans, great help!
-
WSCFDguru
AskWoody LoungerFor a multi-select list box you shouldn’t use the Click event but the Change event.
You can’t just keep on adding items to lsFinish each time the user clicks an item. You’ll have to clear lsFinish and determine which items should be added.I now get an error when I try to run the userform: “Run-time error ‘1004’: Method ‘Range’ of object ‘_Global’ failed”
Any idea why?
-
WSCFDguru
AskWoody LoungerYou can add the items to a Collection object first, with an error handler to suppress the error that occurs when you try to add the same value twice. Then add the members of the Collection to the list box. See Fill a ListBox with unique values from a worksheet using VBA in Microsoft Excel for a code example.
One more question. I have setup the userform as shown in the attached figure. For each selection of Material, I get a list of material types. But when I click on this list box (lsType) nothing shows up on the material finish listbox (lsFinish). Any ideas why?
-
WSCFDguru
AskWoody LoungerClear the list box.
Loop through the filled cells in column A.
Each time the value equals “Aluminum”, use AddItem to add the value from column B to the list box.I got it, thanks Hans. How would I remove duplicates from the listbox?
-
WSCFDguru
AskWoody LoungerYes, that would make it easier – I did the same before importing the table into Access (I also removed the blank rows)
I still not too clear on how to make this in Excel. Let me simplify it further: If I have the following table in Excel in the range from A5 to D9:
Aluminum Al 6061 Anodized 0.50
Aluminum Al 6061 Anodized 1200S 0.49
Aluminum Al 7075-T6 Clear Anodized 0.81
Stainless Steel / CRES Stainless Steel Polished 0.42
Stainless Steel / CRES Stainless Steel Sandblasted 0.58What would be the VBA code if I was looking for the list of material types for, let’s say, Aluminum?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Marriage Counseling – Manages To Do It Save Our Marriage? (Awaiting moderation)
by
lynwoodspellman
2 hours, 50 minutes ago -
Where’s the cache today?
by
Up2you2
2 hours, 43 minutes ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
9 hours, 48 minutes ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
10 hours, 9 minutes ago -
Blocking Search (on task bar) from going to web
by
HenryW
3 hours, 24 minutes ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
19 hours, 57 minutes ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
20 hours, 3 minutes ago -
regarding april update and may update
by
heybengbeng
21 hours, 33 minutes ago -
MS Passkey
by
pmruzicka
28 minutes ago -
Can’t make Opera my default browser
by
bmeacham
1 day, 5 hours ago -
*Some settings are managed by your organization
by
rlowe44
15 hours, 56 minutes ago -
Formatting of “Forward”ed e-mails
by
Scott Mills
1 day, 4 hours ago -
SmartSwitch PC Updates will only be supported through the MS Store Going Forward
by
PL1
1 day, 23 hours ago -
CISA warns of hackers targeting critical oil infrastructure
by
Nibbled To Death By Ducks
2 days, 8 hours ago -
AI slop
by
Susan Bradley
2 hours, 44 minutes ago -
Chrome : Using AI with Enhanced Protection mode
by
Alex5723
2 days, 10 hours ago -
Two blank icons
by
CR2
21 hours, 50 minutes ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
2 days, 19 hours ago -
End of 10
by
Alex5723
2 days, 21 hours ago -
Single account cannot access printer’s automatic duplex functionality
by
Bruce
1 day, 19 hours ago -
test post
by
gtd12345
3 days, 3 hours ago -
Privacy and the Real ID
by
Susan Bradley
2 days, 17 hours ago -
MS-DEFCON 2: Deferring that upgrade
by
Susan Bradley
20 hours, 9 minutes ago -
Cant log on to oldergeeks.Com
by
WSJonharnew
3 days, 8 hours ago -
Upgrading from Win 10
by
WSjcgc50
1 day, 19 hours ago -
USB webcam / microphone missing after KB5050009 update
by
WSlloydkuhnle
1 day, 23 hours ago -
TeleMessage, a modified Signal clone used by US government has been hacked
by
Alex5723
3 days, 23 hours ago -
The story of Windows Longhorn
by
Cybertooth
3 days, 11 hours ago -
Red x next to folder on OneDrive iPadOS
by
dmt_3904
4 days, 1 hour ago -
Are manuals extinct?
by
Susan Bradley
1 day, 2 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.