Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Help with this code please

i have the code :


Private Sub UserForm_activate()
Dim myRng As Range
Dim myCell As Range

With Worksheets("sheet1")
Set myRng = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp))
End With

With Me.ctrlList
For Each myCell In myRng.Cells
.AddItem myCell.Text
Next myCell
End With
'Me.ctrlList.Clear
End Sub

Private Sub DeleteButton_Click()
Dim i As Integer
If Not Cleared Then
With Sheets("Sheet1")
i = Application.Match(Me.ctrlList.Value, Range("C:C"), 0)
Cleared = True
.Range("C:C" & i).EntireRow.Delete Shift:=xlUp
End With
End If
Cleared = False
Me.Hide
End Sub




and i am having 2 problems, the values on the list box regenerate only
when i restart the form not automaticaly eventhough i need to
regenerate when ever i have a new record and the deleting code is not
working , i wanted to be assigned to the list box, whenever i click a
value on the list box and press the delet button , the whole row
having this value shall be deleted from the excel worksheet could you
please help?
i appreciate your help

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Help with this code please

The easiest way is to create a named range for the data in the worksheet,
and set the RowSource property to that named range.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"TheGodfather" wrote in message
oups.com...
i have the code :


Private Sub UserForm_activate()
Dim myRng As Range
Dim myCell As Range

With Worksheets("sheet1")
Set myRng = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp))
End With

With Me.ctrlList
For Each myCell In myRng.Cells
.AddItem myCell.Text
Next myCell
End With
'Me.ctrlList.Clear
End Sub

Private Sub DeleteButton_Click()
Dim i As Integer
If Not Cleared Then
With Sheets("Sheet1")
i = Application.Match(Me.ctrlList.Value, Range("C:C"), 0)
Cleared = True
.Range("C:C" & i).EntireRow.Delete Shift:=xlUp
End With
End If
Cleared = False
Me.Hide
End Sub




and i am having 2 problems, the values on the list box regenerate only
when i restart the form not automaticaly eventhough i need to
regenerate when ever i have a new record and the deleting code is not
working , i wanted to be assigned to the list box, whenever i click a
value on the list box and press the delet button , the whole row
having this value shall be deleted from the excel worksheet could you
please help?
i appreciate your help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Help with this code please

You might want to read up on the UserForm.Show, UserForm.Hide and Unload
Userform methods. With respect to the list being rejuvenated, If you are
using RowSource in the ListBox or ComboBox properties, It should show each
time you show the UserForm. If you are using the UserForm_Initialize event
to load the list then it also should reload the list each time you show the
UserForm. However, I do not see any code in your post that reflects either
of the conditions, nor do I see a reference to either a listbox or combobox.
So I am confused about what ctrlList refers to.

"TheGodfather" wrote:

i have the code :


Private Sub UserForm_activate()
Dim myRng As Range
Dim myCell As Range

With Worksheets("sheet1")
Set myRng = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp))
End With

With Me.ctrlList
For Each myCell In myRng.Cells
.AddItem myCell.Text
Next myCell
End With
'Me.ctrlList.Clear
End Sub

Private Sub DeleteButton_Click()
Dim i As Integer
If Not Cleared Then
With Sheets("Sheet1")
i = Application.Match(Me.ctrlList.Value, Range("C:C"), 0)
Cleared = True
.Range("C:C" & i).EntireRow.Delete Shift:=xlUp
End With
End If
Cleared = False
Me.Hide
End Sub




and i am having 2 problems, the values on the list box regenerate only
when i restart the form not automaticaly eventhough i need to
regenerate when ever i have a new record and the deleting code is not
working , i wanted to be assigned to the list box, whenever i click a
value on the list box and press the delet button , the whole row
having this value shall be deleted from the excel worksheet could you
please help?
i appreciate your help


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Help with this code please

You might want to visit this site for some additional information:

http://support.microsoft.com/default...b;EN-US;829070


"TheGodfather" wrote:

i have the code :


Private Sub UserForm_activate()
Dim myRng As Range
Dim myCell As Range

With Worksheets("sheet1")
Set myRng = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp))
End With

With Me.ctrlList
For Each myCell In myRng.Cells
.AddItem myCell.Text
Next myCell
End With
'Me.ctrlList.Clear
End Sub

Private Sub DeleteButton_Click()
Dim i As Integer
If Not Cleared Then
With Sheets("Sheet1")
i = Application.Match(Me.ctrlList.Value, Range("C:C"), 0)
Cleared = True
.Range("C:C" & i).EntireRow.Delete Shift:=xlUp
End With
End If
Cleared = False
Me.Hide
End Sub




and i am having 2 problems, the values on the list box regenerate only
when i restart the form not automaticaly eventhough i need to
regenerate when ever i have a new record and the deleting code is not
working , i wanted to be assigned to the list box, whenever i click a
value on the list box and press the delet button , the whole row
having this value shall be deleted from the excel worksheet could you
please help?
i appreciate your help


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


All times are GMT +1. The time now is 09:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"