• 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
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Control or macro to enter values in cells|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Control or macro to enter values in cells|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
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 & MacrosControl or macro to enter values in…
sp_PrintTopic sp_TopicIcon
Control or macro to enter values in cells
Avatar
Peter Douglas
Member
Members
Level 0
Forum Posts: 9
Member Since:
July 27, 2020
sp_UserOfflineSmall Offline
1
July 27, 2020 - 1:59 pm
sp_Permalink sp_Print sp_EditHistory

I have setup a worksheet that has 5 buttons on each of 14 columns, the buttons place a 1, 2 ,3 ,4 or 5 in the cell above. The value is use to decide what color the text is in the columns below the buttons. There is also a formula that uses this value to determine if the value is True, False or the Value of 1. buttons.JPGImage Enlarger

I am sure there is a much more efficient way some type of loop perhaps.

This is how I have it at the moment

Private Sub cb1_Click()
Range("C6") = 1
End Sub

Private Sub cb2_Click()
Range("C6") = 2
End Sub

Private Sub cb3_Click()
Range("C6") = 3
End Sub

Private Sub cb4_Click()
Range("C6") = 4
End Sub

Private Sub cb5_Click()
Range("C6") = 5
End Sub

Private Sub cb6_Click()
Range("D6") = 1
End Sub

Private Sub cb7_Click()
Range("D6") = 2
End Sub

Private Sub cb8_Click()
Range("D6") = 3
End Sub

Private Sub cb9_Click()
Range("D6") = 4
End Sub

Private Sub cb10_Click()
Range("D6") = 5
End Sub

Private Sub cb11_Click()
Range("E6") = 1
End Sub

Private Sub cb12_Click()
Range("E6") = 2
End Sub

Private Sub cb13_Click()
Range("E6") = 3
End Sub

Private Sub cb14_Click()
Range("E6") = 4
End Sub

Private Sub cb15_Click()
Range("E6") = 5
End Sub

Private Sub cb16_Click()
Range("F6") = 1
End Sub

Private Sub cb17_Click()
Range("F6") = 2
End Sub

Private Sub cb18_Click()
Range("F6") = 3
End Sub

Private Sub cb19_Click()
Range("F6") = 4
End Sub

Private Sub cb20_Click()
Range("F6") = 5
End Sub

Private Sub cb21_Click()
Range("G6") = 1
End Sub

Private Sub cb22_Click()
Range("G6") = 2
End Sub

Private Sub cb23_Click()
Range("G6") = 3
End Sub

Private Sub cb24_Click()
Range("G6") = 4
End Sub

Private Sub cb25_Click()
Range("G6") = 5
End Sub

Private Sub cb26_Click()
Range("H6") = 1
End Sub

Private Sub cb27_Click()
Range("H6") = 2
End Sub

Private Sub cb28_Click()
Range("H6") = 3
End Sub

Private Sub cb29_Click()
Range("H6") = 4
End Sub

Private Sub cb30_Click()
Range("H6") = 5
End Sub

Private Sub cb31_Click()
Range("I6") = 1
End Sub

Private Sub cb32_Click()
Range("I6") = 2
End Sub

Private Sub cb33_Click()
Range("I6") = 3
End Sub

Private Sub cb34_Click()
Range("I6") = 4
End Sub

Private Sub cb35_Click()
Range("I6") = 5
End Sub

Private Sub cb36_Click()
Range("J6") = 1
End Sub

Private Sub cb37_Click()
Range("J6") = 2
End Sub

Private Sub cb38_Click()
Range("J6") = 3
End Sub

Private Sub cb39_Click()
Range("J6") = 4
End Sub

Private Sub cb40_Click()
Range("J6") = 5
End Sub

Private Sub cb41_Click()
Range("K6") = 1
End Sub

Private Sub cb42_Click()
Range("K6") = 2
End Sub

Private Sub cb43_Click()
Range("K6") = 3
End Sub

Private Sub cb44_Click()
Range("K6") = 4
End Sub

Private Sub cb45_Click()
Range("K6") = 5
End Sub

Private Sub cb46_Click()
Range("L6") = 1
End Sub

Private Sub cb47_Click()
Range("L6") = 2
End Sub

Private Sub cb48_Click()
Range("L6") = 3
End Sub

Private Sub cb49_Click()
Range("L6") = 4
End Sub

Private Sub cb50_Click()
Range("L6") = 5
End Sub

Private Sub cb51_Click()
Range("M6") = 1
End Sub

Private Sub cb52_Click()
Range("M6") = 2
End Sub

Private Sub cb53_Click()
Range("M6") = 3
End Sub

Private Sub cb54_Click()
Range("M6") = 4
End Sub

Private Sub cb55_Click()
Range("M6") = 5
End Sub

Private Sub cb56_Click()
Range("N6") = 1
End Sub

Private Sub cb57_Click()
Range("N6") = 2
End Sub

Private Sub cb58_Click()
Range("N6") = 3
End Sub

Private Sub cb59_Click()
Range("N6") = 4
End Sub

Private Sub cb60_Click()
Range("N6") = 5
End Sub

Private Sub cb61_Click()
Range("O6") = 1
End Sub

Private Sub cb62_Click()
Range("O6") = 2
End Sub

Private Sub cb63_Click()
Range("O6") = 3
End Sub

Private Sub cb64_Click()
Range("O6") = 4
End Sub

Private Sub cb65_Click()
Range("O6") = 5
End Sub

Private Sub cb66_Click()
Range("P6") = 1
End Sub

Private Sub cb67_Click()
Range("P6") = 2
End Sub

Private Sub cb68_Click()
Range("P6") = 3
End Sub

Private Sub cb69_Click()
Range("P6") = 4
End Sub

Private Sub cb70_Click()
Range("P6") = 5
End Sub

Thanks

sp_PlupAttachments Attachments
  • sp_PlupImage buttons.JPG (27 KB)
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
July 27, 2020 - 2:30 pm
sp_Permalink sp_Print

Hi Peter,

You might be able to use a data validation list or a spin button control.

Please supply your workbook so we don't have to recreate everything.

regards

Phil

Avatar
Peter Douglas
Member
Members
Level 0
Forum Posts: 9
Member Since:
July 27, 2020
sp_UserOfflineSmall Offline
3
July 27, 2020 - 2:54 pm
sp_Permalink sp_Print sp_EditHistory

Thanks for your reply, it works but not very well

Please find workbook below

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
July 27, 2020 - 5:11 pm
sp_Permalink sp_Print sp_EditHistory

Hi Peter,

Please see attached file.  On the 'Week Commencing' sheet, C7 uses a drop down list and conditional formatting rules to change the colour of the text in C10:C19.  I've removed the number in C6 as it is redundant in this setup but you can put it back if you like and use the CF rules you already have in place.

D7 uses a spin control and CF rules in a similar way.  I've set up CF rules for D7 to indicate the currently selected colour.

Regards

Phil 

Avatar
Peter Douglas
Member
Members
Level 0
Forum Posts: 9
Member Since:
July 27, 2020
sp_UserOfflineSmall Offline
5
July 27, 2020 - 6:57 pm
sp_Permalink sp_Print

Now that looks great I like the spinner and the colored cell below when you changed, but as I do need the number above as a formula further down the color uses this. Thanks so much for your assistance so simple really. I have another issue which I will post later tonight, I am hoping someone can assist with that

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
July 27, 2020 - 7:04 pm
sp_Permalink sp_Print

no worries.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Catalin Bombea
Guest(s) 9
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
stuart burge
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27295

 

Member Stats:
Guest Posters: 49
Members: 31920
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.