Selection not working

vbastruggle

New Member
Joined
Mar 12, 2018
Messages
6
I have a simple public function within a module. I am planning to execute the function as a user defined function within a worksheet. For now, I only need to select a cell and get its content. This is not working correctly and I hope someone can enlighten me. The simple code from the function is below. If I execute the code from the VBA editor it works fine and I can see that it does, in fact, select Cell D6 on the Test worksheet. However, if I set up a cell with my user defined formula, the code seems to only select from the cell that was previously selected in the worksheet. Can someone please explain why it would work differently when executed in different ways and what I need to do to get the user defined formula to work.

Sheets("Test").Range("D6").Select
MsgBox Selection.Value
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,215,187
Messages
6,123,540
Members
449,107
Latest member
caya

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