Solved

Excel VBA: Finding workbook form belongs to

Posted on 2012-04-11
1
312 Views
Last Modified: 2012-04-11
What VBA code would I need so that when a form in Excel opens, the workbook the form belongs to is stored in a public variable.

e.g., Whenever "ctrl+Y" is pressed the form opens. Therefore if the user is on another workbook and presses "ctrl-y" I would like the form to log the workbook the form belongs to, NOT THE CURRENT workbook.

e.g., putting "activeworkbook.name" in the "On Form Open" sub would not work in this case, as the form could be opened while the user is on another workbook in such case would yield incorrect results.
0
Comment
Question by:ouestque
1 Comment
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 37832599
You can use ThisWorkbook to refer to the book containing code.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now