Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Edit Listbox in Userform


I have a listbox in a userform, I want to edit listbox records, I have
one solution to edit listbox first column, but I dont know how to edit
all Listbox columns.

does any one have any idea, please help me.

Thanks in Advance.

Shahzad

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Edit Listbox in Userform

You can probably use the List property to edit. Check it out in VBA help.

" wrote:


I have a listbox in a userform, I want to edit listbox records, I have
one solution to edit listbox first column, but I dont know how to edit
all Listbox columns.

does any one have any idea, please help me.

Thanks in Advance.

Shahzad


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Edit Listbox in Userform

On Jun 24, 6:46 pm, JLGWhiz wrote:
You can probably use the List property to edit. Check it out in VBA help.



" wrote:

I have a listbox in a userform, I want to edit listbox records, I have
one solution to edit listbox first column, but I dont know how to edit
all Listbox columns.


does any one have any idea, please help me.


Thanks in Advance.


Shahzad- Hide quoted text -


- Show quoted text -



Hi,

I checked the listbox property to Edit, but I could not find some
thing to edit. I am new in this field. pls help me how to edit listbox
row and columns.

Thanks

Shahzad

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Edit Listbox in Userform

Hi ,

You may not be able to edit the multicolumn directly.

See the code below that will let you edit for a single col and you may
extend that for multiple col

Good Luck

Nayan
-------------------------------------------------------------------------------------------
On a user form put a listbox and 2 command buttons...

Private Sub CommandButton1_Click()

ListBox1.AddItem "USA"
ListBox1.AddItem "Canada"
ListBox1.AddItem "London"


End Sub

Private Sub CommandButton2_Click()

Dim sNewListValue As String
sNewListValue = InputBox("Change value", "Edit List",
ListBox1.List(ListBox1.ListIndex))
ListBox1.RemoveItem ListBox1.ListIndex
ListBox1.AddItem sNewListValue

End Su
-----------------------------------------------------------------------------------------------
" wrote:


I have a listbox in a userform, I want to edit listbox records, I have
one solution to edit listbox first column, but I dont know how to edit
all Listbox columns.

does any one have any idea, please help me.

Thanks in Advance.

Shahzad


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Edit Listbox in Userform

Here is all the code you need for updating multicolumn list box

Insert a listbox and 2 cmd controls as listed in code below.

Hope this helps,

Nayan
-----------------------------------------------------------------------------

Private Sub CommandButton3_Click()

Dim sNewValueCol1 As String
Dim sNewValueCol2 As String
Dim sNewValueCol3 As String

sNewValueCol1 = InputBox("Change the values in Col 1", "Edit", "")
sNewValueCol2 = InputBox("Change the values in Col 2", "Edit", "")

i = ListBox1.ListIndex

ListBox1.List(i, 0) = sNewValueCol1
ListBox1.List(i, 1) = sNewValueCol2

End Sub

-----------------------------------------------------------------------------------------------
Private Sub CommandButton1_Click()

Dim sMyRange as string

sMyRange = ActiveSheet.Range("A65536").End(xlUp).Row

Dim ListArray()
MyArray = Range("A1:B" & sMyRange )
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "20;20"
Me.ListBox1.List = MyArray

End Sub

------------------------------------------------------------------------------

"Nayan" wrote:

Hi ,

You may not be able to edit the multicolumn directly.

See the code below that will let you edit for a single col and you may
extend that for multiple col

Good Luck

Nayan
-------------------------------------------------------------------------------------------
On a user form put a listbox and 2 command buttons...

Private Sub CommandButton1_Click()

ListBox1.AddItem "USA"
ListBox1.AddItem "Canada"
ListBox1.AddItem "London"


End Sub

Private Sub CommandButton2_Click()

Dim sNewListValue As String
sNewListValue = InputBox("Change value", "Edit List",
ListBox1.List(ListBox1.ListIndex))
ListBox1.RemoveItem ListBox1.ListIndex
ListBox1.AddItem sNewListValue

End Sub
-----------------------------------------------------------------------------------------------
" wrote:


I have a listbox in a userform, I want to edit listbox records, I have
one solution to edit listbox first column, but I dont know how to edit
all Listbox columns.

does any one have any idea, please help me.

Thanks in Advance.

Shahzad




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Edit Listbox in Userform

On Jun 25, 10:30 pm, Nayan wrote:
Here is all the code you need for updating multicolumn list box

Insert a listbox and 2 cmd controls as listed in code below.

Hope this helps,

Nayan
---------------------------------------------------------------------------*--

Private Sub CommandButton3_Click()

Dim sNewValueCol1 As String
Dim sNewValueCol2 As String
Dim sNewValueCol3 As String

sNewValueCol1 = InputBox("Change the values in Col 1", "Edit", "")
sNewValueCol2 = InputBox("Change the values in Col 2", "Edit", "")

i = ListBox1.ListIndex

ListBox1.List(i, 0) = sNewValueCol1
ListBox1.List(i, 1) = sNewValueCol2

End Sub

---------------------------------------------------------------------------*--------------------
Private Sub CommandButton1_Click()

Dim sMyRange as string

sMyRange = ActiveSheet.Range("A65536").End(xlUp).Row

Dim ListArray()
MyArray = Range("A1:B" & sMyRange )
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "20;20"
Me.ListBox1.List = MyArray

End Sub

---------------------------------------------------------------------------*---



"Nayan" wrote:
Hi ,


You may not be able to edit the multicolumn directly.


See the code below that will let you edit for a single col and you may
extend that for multiple col


Good Luck


Nayan
---------------------------------------------------------------------------*----------------
On a user form put a listbox and 2 command buttons...


Private Sub CommandButton1_Click()


ListBox1.AddItem "USA"
ListBox1.AddItem "Canada"
ListBox1.AddItem "London"


End Sub


Private Sub CommandButton2_Click()


Dim sNewListValue As String
sNewListValue = InputBox("Change value", "Edit List",
ListBox1.List(ListBox1.ListIndex))
ListBox1.RemoveItem ListBox1.ListIndex
ListBox1.AddItem sNewListValue


End Sub
---------------------------------------------------------------------------*--------------------
" wrote:


I have a listbox in a userform, I want to edit listbox records, I have
one solution to edit listbox first column, but I dont know how to edit
all Listbox columns.


does any one have any idea, please help me.


Thanks in Advance.


Shahzad- Hide quoted text -


- Show quoted text -




Hi, Nayan,

Thank you for your support and prompt reply. I tried your code but it
is update only userform, not in the worksheet.

Can you pls check again when I Edit multicolumn as per your code, then
worksheet data should be changed.

Waiting for your reply.

Thanks and Regards.

syed shahzad


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Edit Listbox in Userform


Syed,

Are you saying that you populate a list from columns; in excel worksheet and
then edit these columns in worksheets using this list box ?

If that is the case then You can user range object of worksheet to point to
a particular cell.
Array value from this code that updates the list box can be passed to the
cell reference and that will update list box as well as cell in worksheet.

application.worksheets(name of worksheet).range( refer to cell with 'col A'
and 'Row i' here).value = sNewValueCol1
application.worksheets(name of worksheet).range( refer to cell with 'col B'
and 'Row i' here).value = sNewValueCol2

Hope this helps

Nayan

" wrote:

On Jun 25, 10:30 pm, Nayan wrote:
Here is all the code you need for updating multicolumn list box

Insert a listbox and 2 cmd controls as listed in code below.

Hope this helps,

Nayan
------------------------------------------------------------------------------

Private Sub CommandButton3_Click()

Dim sNewValueCol1 As String
Dim sNewValueCol2 As String
Dim sNewValueCol3 As String

sNewValueCol1 = InputBox("Change the values in Col 1", "Edit", "")
sNewValueCol2 = InputBox("Change the values in Col 2", "Edit", "")

i = ListBox1.ListIndex

ListBox1.List(i, 0) = sNewValueCol1
ListBox1.List(i, 1) = sNewValueCol2

End Sub

------------------------------------------------------------------------------------------------
Private Sub CommandButton1_Click()

Dim sMyRange as string

sMyRange = ActiveSheet.Range("A65536").End(xlUp).Row

Dim ListArray()
MyArray = Range("A1:B" & sMyRange )
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "20;20"
Me.ListBox1.List = MyArray

End Sub

-------------------------------------------------------------------------------



"Nayan" wrote:
Hi ,


You may not be able to edit the multicolumn directly.


See the code below that will let you edit for a single col and you may
extend that for multiple col


Good Luck


Nayan
--------------------------------------------------------------------------------------------
On a user form put a listbox and 2 command buttons...


Private Sub CommandButton1_Click()


ListBox1.AddItem "USA"
ListBox1.AddItem "Canada"
ListBox1.AddItem "London"


End Sub


Private Sub CommandButton2_Click()


Dim sNewListValue As String
sNewListValue = InputBox("Change value", "Edit List",
ListBox1.List(ListBox1.ListIndex))
ListBox1.RemoveItem ListBox1.ListIndex
ListBox1.AddItem sNewListValue


End Sub
------------------------------------------------------------------------------------------------
" wrote:


I have a listbox in a userform, I want to edit listbox records, I have
one solution to edit listbox first column, but I dont know how to edit
all Listbox columns.


does any one have any idea, please help me.


Thanks in Advance.


Shahzad- Hide quoted text -


- Show quoted text -




Hi, Nayan,

Thank you for your support and prompt reply. I tried your code but it
is update only userform, not in the worksheet.

Can you pls check again when I Edit multicolumn as per your code, then
worksheet data should be changed.

Waiting for your reply.

Thanks and Regards.

syed shahzad



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Edit Listbox in Userform

On Jun 26, 9:53 pm, Nayan wrote:
Syed,

Are you saying that you populate a list from columns; in excel worksheet and
then edit these columns in worksheets using this list box ?

If that is the case then You can user range object of worksheet to point to
a particular cell.
Array value from this code that updates the list box can be passed to the
cell reference and that will update list box as well as cell in worksheet.

application.worksheets(name of worksheet).range( refer to cell with 'col A'
and 'Row i' here).value = sNewValueCol1
application.worksheets(name of worksheet).range( refer to cell with 'col B'
and 'Row i' here).value = sNewValueCol2

Hope this helps

Nayan



" wrote:
On Jun 25, 10:30 pm, Nayan wrote:
Here is all the code you need for updating multicolumn list box


Insert a listbox and 2 cmd controls as listed in code below.


Hope this helps,


Nayan
---------------------------------------------------------------------------*---


Private Sub CommandButton3_Click()


Dim sNewValueCol1 As String
Dim sNewValueCol2 As String
Dim sNewValueCol3 As String


sNewValueCol1 = InputBox("Change the values in Col 1", "Edit", "")
sNewValueCol2 = InputBox("Change the values in Col 2", "Edit", "")


i = ListBox1.ListIndex


ListBox1.List(i, 0) = sNewValueCol1
ListBox1.List(i, 1) = sNewValueCol2


End Sub


---------------------------------------------------------------------------*---------------------
Private Sub CommandButton1_Click()


Dim sMyRange as string


sMyRange = ActiveSheet.Range("A65536").End(xlUp).Row


Dim ListArray()
MyArray = Range("A1:B" & sMyRange )
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "20;20"
Me.ListBox1.List = MyArray


End Sub


---------------------------------------------------------------------------*----


"Nayan" wrote:
Hi ,


You may not be able to edit the multicolumn directly.


See the code below that will let you edit for a single col and you may
extend that for multiple col


Good Luck


Nayan
---------------------------------------------------------------------------*-----------------
On a user form put a listbox and 2 command buttons...


Private Sub CommandButton1_Click()


ListBox1.AddItem "USA"
ListBox1.AddItem "Canada"
ListBox1.AddItem "London"


End Sub


Private Sub CommandButton2_Click()


Dim sNewListValue As String
sNewListValue = InputBox("Change value", "Edit List",
ListBox1.List(ListBox1.ListIndex))
ListBox1.RemoveItem ListBox1.ListIndex
ListBox1.AddItem sNewListValue


End Sub
---------------------------------------------------------------------------*---------------------
" wrote:


I have a listbox in a userform, I want to edit listbox records, I have
one solution to edit listbox first column, but I dont know how to edit
all Listbox columns.


does any one have any idea, please help me.


Thanks in Advance.


Shahzad- Hide quoted text -


- Show quoted text -


Hi, Nayan,


Thank you for your support and prompt reply. I tried your code but it
is update only userform, not in the worksheet.


Can you pls check again when I Edit multicolumn as per your code, then
worksheet data should be changed.


Waiting for your reply.


Thanks and Regards.


syed shahzad- Hide quoted text -


- Show quoted text -



Dear Mr. Nayan,

I am very happy to see that you sent me reply within one hour. I
appreciated ...
Sir, the code you sent, I checked but it is not working in my form.
May be I am doing some thing wrong.

Actually I have a Worksheet name is DATA, having Inventory Data from
A2:M99

and I have a userform1, showing one combobox1 and other textboxes to
display the data. I am using combobox to retrive data, by using this
code:


Option Explicit
Dim i As Integer

Private Sub ComboBox1_Change()

i = ComboBox1.ListIndex

TextBox1.Value = ComboBox1.Column(1, i) 'This is column B
TextBox2.Value = ComboBox1.Column(2, i) 'This is column C
TextBox3.Value = ComboBox1.Column(3, i) 'This is column D
TextBox4.Value = ComboBox1.Column(4, i) 'This is column E
TextBox5.Value = ComboBox1.Column(5, i) 'This is column F
TextBox6.Value = ComboBox1.Column(6, i) 'This is column G
TextBox7.Value = ComboBox1.Column(7, i) 'This is column H
TextBox8.Value = ComboBox1.Column(8, i) 'This is column I
TextBox9.Value = ComboBox1.Column(9, i) 'This is column J
TextBox10.Value = ComboBox1.Column(10, i) 'This is column K
TextBox11.Value = ComboBox1.Column(11, i) 'This is column L
TextBox12.Value = ComboBox1.Column(12, i) 'This is column M

End Sub

Private Sub CommandButton1_Click()

Unload Me

End Sub


Private Sub UserForm_Initialize()

ComboBox1.SetFocus
ComboBox1.RowSource = "A2:N99"

End Sub


NOW, the problem is this after retriving my records from the
worksheet, I am unable to Edit, if I want to change any record
(textbox) how I can Edit my records in userform and the worksheet at
the same time.

this is my big problem.

If you send me the solution, I will be highly appreciated.

Very sorry to distrub you again and again.

Thanks and regards.

Syed Shahzad Zafar
Madinah - KSA






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
Edit cell contents via userform listbox N E Body[_15_] Excel Programming 0 October 22nd 04 04:49 PM
Edit cell contents via userform listbox N E Body[_14_] Excel Programming 1 October 22nd 04 01:44 AM
Edit cell contents via userform listbox N E Body[_13_] Excel Programming 1 October 21st 04 01:13 AM
Edit cell contents via userform listbox N E Body[_12_] Excel Programming 1 October 20th 04 01:49 AM
Edit cell contents via userform listbox N E Body[_11_] Excel Programming 1 October 19th 04 03:16 AM


All times are GMT +1. The time now is 02:20 PM.

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

About Us

"It's about Microsoft Excel"