• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Checkbox Values Population Location|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Checkbox Values Population Location|VBA & Macros|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosCheckbox Values Population Location
sp_PrintTopic sp_TopicIcon
Checkbox Values Population Location
Avatar
Nathan Ulrich

New Member
Members
Level 0
Forum Posts: 2
Member Since:
October 21, 2020
sp_UserOfflineSmall Offline
1
October 21, 2020 - 7:13 pm
sp_Permalink sp_Print sp_EditHistory

Hi All,

 

Excuse my Novas question, I am a complete rookie when it comes to VBA.

 

I am currently using the below code to populate the values of checkboxes to enable the ability to add all activated checkboxes. As the sheet contains a lot of checkboxes and not just a single row, the values of the boxes is becoming messy and hard to differentiate between them.

Ideally I would like to have all checkbox values populate to a separate sheet and have the ability to have them grouped based on the rows of the correlating checkboxes on the previous sheet. This would allow me to use the countif (x:x,true) function to total the values. 

Currently the code takes all checkboxes values and runs them in a continued column on the same sheet.

I am also open to alternative ways to achieve the same outcome.

Sub LinkChecks()
'Update 20150310
i = 2
For Each cb In ActiveSheet.CheckBoxes
cb.LinkedCell = Cells(i, "B").Address
i = i + 1
Next cb
End Sub

Thank you

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1530
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
October 22, 2020 - 7:43 pm
sp_Permalink sp_Print

Hi Nathan,

Can you please supply your workbook.  It'll be easier for me to understand what you are trying to do if I can see the sheet(s).

Regards

Phil

Avatar
Nathan Ulrich

New Member
Members
Level 0
Forum Posts: 2
Member Since:
October 21, 2020
sp_UserOfflineSmall Offline
3
October 23, 2020 - 1:04 pm
sp_Permalink sp_Print

Hi Philip,

 

Thank you for your response. I have provided the workbook attached. I have added some additional comments into the sheet "Value Locations".

 

Please let me know if you need further information.

 

Thank you

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1530
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
October 24, 2020 - 5:22 pm
sp_Permalink sp_Print

Hi Nathan,

You said you were open to alternative approaches so how about this.  Rather than using checkboxes, I'm using Worksheet_SelectionChange events to check what cells are being clicked in.  If you click into a cell related to a Vehicle/Date the macro fills that cell in with green and places the value 1 into it.

The number is also green so you can't see it.  It just looks like a green cell, but because there are numbers in each cell you can use formulas like SUM to count up how many cells are filled in/clicked.

I've created a new sheet called MOTH in the attached workbook. Open it and go into the VBA editor you will see in the Sheet3(MOTH) code module the VBA that does all of this.

I've created 2 named ranges Nov and Dec that refer to the relevant cells for those months.  Nov refers to MOTH!$C$3:$AF$7 and Dec refers to MOTH!$C$11:$AF$15.

If you add more months then create a named range for each. You will also need to add code in the event to check for clicks into this new named range.  You'll need to add to this line for each new named range.

If Not Intersect(Target, ActiveSheet.Range ("Nov")) Is Nothing Or Not Intersect (Target, ActiveSheet.Range ("Dec")) Is Nothing Then

You can change the cell and font colour to whatever you like.

Let me know if you need to adapt this further.

Useful reading on events:

Workbook and Worksheet Events in VBA

regards

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Louis Muti
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Blair Gallagher
Brandi Taylor
Hafiz Ihsan Qadir
Gontran Bage
adolfo casanova
Annestine Johnpulle
Priscila Campbell
Jeff Mikles
Aaron Butler
Maurice Petterlin
Forum Stats:
Groups: 3
Forums: 24
Topics: 6369
Posts: 27852

 

Member Stats:
Guest Posters: 49
Members: 32359
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.