• 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

Worksheet Change and Selection Change not working as Intended|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Worksheet Change and Selection Change not working as Intended|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 & MacrosWorksheet Change and Selection Chan…
sp_PrintTopic sp_TopicIcon
Worksheet Change and Selection Change not working as Intended
Avatar
Graham Michel

Active Member
Members

Power BI
Level 0
Forum Posts: 3
Member Since:
May 17, 2019
sp_UserOfflineSmall Offline
1
July 24, 2020 - 6:36 pm
sp_Permalink sp_Print

Good Morning, I have been trying to resolve an issue for some 2 weeks whereby I have been using  WS_Change Event to lookup data and now reading Phillip’s article yet again (properly this time), I realise it may be WS_SelectionChange that I should be using although still have issues using either alternative.

Use: In the Summary WS of the attached (where the Change Event is), Line 27 is the top row of a table, there is a dropdown data validated list on C27 from which the user should select a  StockCode and the Event returns the Description from the SqlData table. I also want to return the Group and Selling Price when I can get it working correctly. Tab through the remaining cells to add a new line to the Table and repeat the process as often as required thereby expanding the Table.

Using WS Change: 1st line populates correctly but tab to 2nd and subsequent lines, repeats the Description across all cells in the line and also adds an additional column on each line.

Using WS SelectionChange: “flashes” on StockCode Cell and Validation List selector disappears. It is only by putting a break on the code that allows user input to the Drop Down Selection that a code can be selected. After that, it correctly adds the Description and tabbing through correctly adds the new line with correct number of columns and then this series of actions repeats.

I have tried Enable/Disable Events but without much success due to my lack of understanding.

I’m sorry if this explanation appears excessive but I didn’t want to waste anybody’s time who was prepared to try and assist with this problem and thank you in anticipation of any assistance or suggestions offered.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1510
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
July 25, 2020 - 11:44 am
sp_Permalink sp_Print

Hi Graham,

You don't need VBA to do this, just use a lookup function like VLOOKUP or XLOOKUP.  See attached.

Regards

Phil

Avatar
Graham Michel

Active Member
Members

Power BI
Level 0
Forum Posts: 3
Member Since:
May 17, 2019
sp_UserOfflineSmall Offline
3
July 25, 2020 - 4:55 pm
sp_Permalink sp_Print

'Morning Phil, thanks for the reply

Yes, I had already got this working with Index & Match (as the Group column would have required a negative Lookup) as a Backup. However, as the data is then to be used elsewhere, you would need to make them all the Index/Match permanent by Copy & Paste Special of the 3 formulas over what may be anything from 10 to 00's or even a 1000 or so lines.

I was also trying to increase my knowledge and use of VBA by getting the Change Events functionality working as it will come up again in a future requirement.

Thank you for looking, I appreciate your time!

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1510
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
July 26, 2020 - 11:03 am
sp_Permalink sp_Print

Hi Graham,

Not quite following why you can't use formulae, you need to copy/paste the values?  When you add a row to the table the formulae in the last filled row are copied down to the new row.

Regards

Phil

Avatar
Graham Michel

Active Member
Members

Power BI
Level 0
Forum Posts: 3
Member Since:
May 17, 2019
sp_UserOfflineSmall Offline
5
July 26, 2020 - 6:34 pm
sp_Permalink sp_Print

'Morning Phil, yes, I realise that the formulas will copy in a table but when the user has finished building the table with n number of additional rows, that block of data is to be moved elsewhere and everything will Error unless Copy/Paste is used. I wanted to avoid showing the formula and then dealing with Copy/Paste by making the whole thing appear seemless by employing WS Selection or Change Events and it seemed a perfect opportunity to use the VBA functionality to perform the task and I know it will come in useful in the future if I could master the technique on this piece of work.

Thanks again for looking

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: David, yonatan zelig, Christopher Anderson
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
yashal minahil
Oluwadamilola Ogun
Yannik H
dectator mang
Francis Drouillard
Orlando Inocente
Jovitha Clemence
Maloxat Axmatovna
Ricardo Freitas
Marko Meglic
Forum Stats:
Groups: 3
Forums: 24
Topics: 6200
Posts: 27182

 

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