KestutisTower
New Member
- Joined
- Jun 2, 2022
- Messages
- 23
- Office Version
- 2016
- Platform
- Windows
Hello everybody,
I have a userform with listbox1 and textbox1 and comandbutton1.
Listbox is populated by RowSource property with named range( in sheet1).its product names.
Sheet1
also, i have a sheet2 witch has same product names( but different order)
sheet2
what i need to do is... when i select an item in listbox1 and enter value in textbox1, and press on comandbutton1(Enter price), textbox1 value to be copied to column C in sheet1 maching row,
and sheet2 column B maching row.
I can get first bit working with this code:
but I can't get the second bit going. Please help!!
I have a userform with listbox1 and textbox1 and comandbutton1.
Listbox is populated by RowSource property with named range( in sheet1).its product names.
Sheet1
Book1 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | ID | Product | Price | ||
2 | 1 | tv | |||
3 | 2 | radio | |||
4 | 2 | mp3 | |||
Sheet1 |
also, i have a sheet2 witch has same product names( but different order)
sheet2
Book1 | ||||
---|---|---|---|---|
A | B | |||
1 | Product | Price | ||
2 | tv | |||
3 | radio | |||
4 | mp3 | |||
Sheet1 |
what i need to do is... when i select an item in listbox1 and enter value in textbox1, and press on comandbutton1(Enter price), textbox1 value to be copied to column C in sheet1 maching row,
and sheet2 column B maching row.
I can get first bit working with this code:
VBA Code:
Private Sub Comandbutton1_Click()
Dim sh As Worksheet
Set sh = ThisWorkbook.Worksheets("Sheet1")
Dim lRw As Long
lRw = lstEile.ListIndex + 1
With sh
.Cells(lRw, 3).Value = textbox1.Value
End With
textbox1.Value = ""
End Sub