Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2007, 04:44 PM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Deleting selected row in ListBox

Hi guys, newbie here.

I've been working on this project for weeks, and cant seem to make this one feature work.

I have a ListBox called ListBox1 that uses RowSource for the data.

Now what I would really like is to be able to delete a row from the worksheet depending on the item selected in the ListBox. I have used the delete last row method, but because the ListBox contains alot of data, I would prefer to have ability to select the item I wanted to delete.

Any help?

Much Appreciated,

Nick

 
Old April 19th, 2007, 09:14 AM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey guys,

Looks like I don't need your help. After looking at how to loop and delete entire rows, I have managed to find it. For those of you interested, here it is:

Code:
Dim r1 As Range

Set r1 = Range("A41:A45")

For Each c1 In r1

    If c1.Value = ListBox1.Value Then
    c1.Font.Bold = True
      With c1
      c1.EntireRow.Delete
       End With
    End If

Next c1
Thanks anyway!






Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting records based on selected checkbox lakshmi_annayappa Javascript 3 September 6th, 2007 02:22 AM
Deleting files using a listbox control Indo77 ASP.NET 1.0 and 1.1 Basics 1 April 20th, 2006 10:43 AM
Deleting every other row Russ Thompson Beginning VB 6 1 December 15th, 2004 05:20 AM
How to get selected Item from Listbox? Iceman571 ADO.NET 1 March 25th, 2004 06:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.