macro to include "user select"

S

Silvabod

Col A is sequential mumber list 1 - 90. (61 currently used - allowed 90 for
"expansion").
Col B is a list of names, with associated data in 7 cols C - I (truncated
layout below).
Col B1:B90 is rangenamed "names" (for function F5 "goto" purpose)

I want to macro "delete" function (to user-select any one of the 90 names),
CLEAR the cells B - I in that row, then "data/sort" the entire range to
remove the blank.

Got most of it by "recording" but came unstuck with the "user select".

A B C D E F G H I
1 alex 1 2 3 4 5 6 paid
2 fred 8 9 10 11 12 14 paid
3 james 3 4 5 6 7 8 paid
4 zoe 7 8 9 10 11 12 paid

(user-select) B2 ..I2, delete. select range A1:I4, data/sort by Col B -
Question is how to pause for user input to choose name to delete? Relative
novice, I am!
And - would be nice to have "another deletion? Y/N? to loop if answer "Y".
 
B

Bob Phillips

Here is an example

Sub DeleteData()
Dim cell As Range

Set cell = Application.InputBox("Select a name to delete", Type:=8)
If Not cell Is Nothing Then
Rows(cell.Row).Delete
End If

End Sub

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
J

JE McGimpsey

Minor addition:

If the user cancels from that macro, they'll get a run-time error.

This macro will loop until they cancel so that they can delete multiple
times.

Public Sub DeleteData()
Dim cell As Range
Do
On Error Resume Next
Set cell = Application.InputBox( _
Prompt:="Select a name to delete", _
Type:=8)
On Error GoTo 0
If cell Is Nothing Then Exit Do
Rows(cell.Row).Delete
Set cell = Nothing
Loop
End Sub
 
S

Silvabod

Thank you both. Now have another problem - can't get into the macro to edit
it !!
Opened the worksheet, to be presented with the "macros disabled - security"
message. Have reduced security down to "lowest" but STILL can't get the
"edit" function in macros (greyed out).
What's happened? How do I get into it?

Possibly relevant - XP Home. I am sole user/administrator, do not "log in",
no password.
Oddly - sending an e_mail, just before opening Excel2003 - OE6 required it
to be digitally signed (and I hadn't set it that way - found the item
ticked, unticked it, message sent)

Have AV, Spybot - MSAntispyware - never had a virus on this pc, and none now
(new pc, 1 month old)

What's the solution, please?
 

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