How To call Worksheet_Change event from a different module

Nerisha

New Member
Joined
Nov 26, 2010
Messages
26
Hi.

I want to be able to call the worksheet_Change function from a different module on my excel workbook. I have code working properly when I call it from the actual sheet, but this sheet gets created via code, so I need the "Worksheet_change" event code to be added automatically as well. Can anyone help me?
 
For this, I need to remove the ToSql function, as it exists in a different module that wont be available when the worksheet_change event is fired. This is the reason for trying to remove it.

I basically need "Item" to have quotations when the query is executed.
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I am trying, with no results to get this query displayed:
sql = "SELECT AmountExcl, ItemDescr FROM Items WHERE ItemDescr = '" & Item & "'"

I'm so close to getting this right, if only I knew how to write the line of code, to that when I open the Worksheet_Change event, it looks like the above.
 
Upvote 0
Ok, I got that working now. One other thing. The code works great, but when I run it, it opens up in the VBA editor, and not the sheet itself. How to I set the focus such that after the code is run, the focus is on the sheet.
 
Upvote 0
Hi there, with regards to your code to "Insert Lines", this works great, but after it executes, it stays in the VBA editor. How can I get it to return to the datasheet view?
 
Upvote 0

Forum statistics

Threads
1,216,120
Messages
6,128,948
Members
449,480
Latest member
yesitisasport

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