Quite some time ago, an EEEEEE* wrote the following VBA code for me which has been great and functioned just as I wanted it to.
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) If Not Intersect(Target, Range("O:O")) Is Nothing Then rowsel = Target.Row Range("O1").Value = Range("K" & rowsel).Value End IfEnd Sub
Recently, I attempted to insert the code into another workbook where I desired the same functionality, but apparently I did something wrong in the process. Here is the before:
and here is the after:
Question: What are the correct steps for copy/pasting this VBA code from one Excel (2013) workbook into another?
After copying the code from the functioning workbook, I inserted it into the second workbook by right-clicking "ThisWorkbook" then selecting "Insert." However, at that point , I did not know which option to choose. In this case the options included:
• UserForm
• Module
• Class Module
but obviously, as (under) stated by the knight of antiquity in Indiana Jones and the last Crusade, "I chose poorly."
Fortunately the flesh has not rotted off my face but I have been beset by a non-functioning code.
It is not uncommon that I Google some topic or post a question on EE and the best resulting solution ends up being something using VBA. However, almost never is the code followed by directions explaining exactly how it should be inserted. Consequently, I usually have to just guess as I did in this case.
Question: Are there any basic clues or guidelines that someone like myself — who has no programming background and does not know VBA — can use to at least correctly determine how/where to insert code when needed?
Thanks
PS I also cannot figure out how to remove the errantly inserted "Class Module" (if indeed it needs to be removed).
* EEEEEE: "Extraordinarily Excellent Experts-Exchange Excel Expert" (to raise the bar a notch on ssaqibh — see here)
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
-Mike Kapnisakis, Warner Bros
With your subscription - you'll gain access to our exclusive IT community of thousands of IT pros. You'll also be able to connect with highly specified Experts to get personalized solutions to your troubleshooting & research questions. It’s like crowd-sourced consulting.
We can't always guarantee that the perfect solution to your specific problem will be waiting for you. If you ask your own question - our Certified Experts will team up with you to help you get the answers you need.
Our certified Experts are CTOs, CISOs, and Technical Architects who answer questions, write articles, and produce videos on Experts Exchange. 99% of them have full time tech jobs - they volunteer their time to help other people in the technology industry learn and succeed.
We can't guarantee quick solutions - Experts Exchange isn't a help desk. We're a community of IT professionals committed to sharing knowledge. Our experts volunteer their time to help other people in the technology industry learn and succeed.
Our community of experts have been thoroughly vetted for their expertise and industry experience.