VBA Code User Range Selection

J

jimbo

I have a current VBA and I would like to extend it to do the following after
the last command:-
allow a user to select a un pretermined range for deletion (could be any
number of coumns and rows) and for the macro to delete that range and either
restart the macro to continue with it's next command or alternatively to stop
via perhaps a message box instruction for the user .
 
M

Mike H

Hi,

Try this, when the input box pops up simply drag to select a range

Set deleterange = Application.InputBox(prompt:="Select a range of cells",
Type:=8)

Mike
 
J

jimbo

Mike hi thanks for replying. Your suggestion works fine up to displaying a
message box and allows the user to select the range. However if the user
selects OK in the message box is does not delete the selected range. Can you
help further?

Many thanks
 
M

Mike H

Hi,

Like this

Set DeleteRange = Application.InputBox(prompt:="Select a range of cells",
Type:=8)
DeleteRange.ClearContents

Mike
 
C

Chip Pearson

range for deletion
Be careful when using the word "delete". Strictly speaking, it means
to remove the range from the worksheet and shifting the appropriate
rows and columns upwards and to the left. If you merely want to remove
the content of the cells, use the term "clear".

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top