VBA script won't run

TomM

New Member
Joined
Dec 17, 2010
Messages
8
I am trying without success to get a basic VBA script to run (I copied/pasted it from http://www.mrexcel.com/forum/showthread.php?t=1321).

I saved code to a new module under the current workbook in the VBA Project pane, and then saved workbook as a .xlsm file. I can't get script to run, namely, it has no effect. Am I missing something obvious here?

Thanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
TomM,

The link you posted is for the Worksheet_SelectionChange Event.

This code does not go into a Module.


Follow the below instructions.


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Select the worksheet in which your code is to run
3. Right click on the sheet tab and choose View Code, to open the Visual Basic Editor
4. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
5. Press the keys ALT + Q to exit the Editor, and return to Excel


Then make a single selection to a cell in that worksheets column A.


How about explaining what you are actually trying to do?
 
Last edited:
Upvote 0
hiker95-

That works just great. FYI, I can make a selection change anywhere in the worksheet -- not just column A -- to activate this subroutine.

Why I am trying to do this:
I have a form which gets populated via VLOOKUP functions from another worksheet; cells are set to wrap and are not merged. I need cells in the form to autofit the row height since number of lines of text can change. However, they won't autofit when populated via a lookup -- I have to toggle the AutoFit command, or click on the row border. Note that autofit works as expected when I copy and paste the actual values.

Thanks much.
 
Upvote 0

Forum statistics

Threads
1,216,150
Messages
6,129,154
Members
449,488
Latest member
qh017

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top