jblack
jblack

Reputation: 576

Run Worksheet_SelectionChange event while Inputbox active

I have an inputbox set up to ask a user to select a range. When selecting the range I would like the selection to automatically be resized to certain dimensions, so the user can see the new selection before clicking OK (before setting myRange).

I have set up a Worksheet_SelectionChange event to handle resizing the selection. The problem is that the selectionChange event doesn't work while the inputbox is active.

This is the code snippet that appears in my module:

InputboxActive=True   
    Set myRange = Application.InputBox("Select a range", "Range Selection", Type:=8)
InputboxActive=False

This code appears in my worksheetChange sub:

if InputboxActive=True then Target.resize(5,10).select

The selectionChange event doesn't run while the inputbox is active. How do I fix this?

Any assistance would be appreciated, thanks

Upvotes: 0

Views: 66

Answers (1)

PaichengWu
PaichengWu

Reputation: 2689

Add myRange.Select after you set myRange, which as

Set myRange = Application.InputBox("Select a range", "Range Selection", Type:=8)
myRange.Select

That should trigger the Worksheet_SelectionChange event

Upvotes: 0

Related Questions