Delete records in a worksheet

R

rixanna

I'm working on a simple program that lets the user enter, edit and
print the data. I developed the program using Microsoft Excel 2003 with
VBE.

The problem is that, under Edit button I want to enable the user to
edit the existing data and save as well as to save as another name.

But, how to let the user delete the data in the worksheet?

Example :
When the user clicked on Delete button, an input box will appear as to
ask which data to be deleted. When the user entered the name of the
file, it will automatically delete the entire data corresponding to the
filename.

There are 2 datas with 3 sub-datas in a worksheet named BOOK TABLE.
a)Data : Fish
Sub-data : Whale, Jelly fish, Jaws
b)Flower
Sub-data : Rose, Sunflower, Tulip

When the user asked to delete the data for Fish, it will automatically
erase all the data and sub-data.

Any ideas?
Thanks in advanced
 
G

glenton (glenton

a simple loop from the bottom of your data table to the top, deleting entire
rows when appropriate should do the trick.

something like
Sub delete()

MyDel = InputBox("Delete?")

For i = Range("a1:a10000").Count To 1 Step -1
If Cells(i + 3, "a") = MyDel Then
Cells(i + 3, "a").EntireRow.delete
End If
Next i

End Sub

Hope this helps

Glenton
 

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