最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

excel - Sending items in Listbox on userform to Worksheet Row - Stack Overflow

programmeradmin5浏览0评论

I've put together a userform and have attached a row of transfers from textboxes and a listbox. The listbox consists of a single column of items however everytime it transfers over it remains in a column which is then overwriten by the next time the the button is pressed.

Ideally I am trying to change it so the listbox items are transferred along the same row as the textbox data with listbox items beginning at O and potentially ending at HF (say a range of 200 items).

Any help with identifying where I've potentially mucked up the listbox transfer would be amazing.

Private Sub cmdPay_Click()

Dim CustomerName As String
Dim CustomerMobile As String
Dim CustomerEmail As String
Dim CustomerAddress As String
Dim TransactionType As String
Dim PaymentType As String
Dim Subtotal As String
Dim Discount As String
Dim Total As String
Dim CustomerPayment As String
Dim ListItem


CustomerName = txtbName.Value
CustomerMobile = txtbMobile.Value
CustomerEmail = txtbEmail.Value
CustomerAddress = txtbAddress.Value
TransactionType = txtTransactionType.Value
PaymentType = txtcboPayment.Value
Subtotal = txtSubtotal.Value
Discount = txtTax.Value
Total = txtTotal.Value
CustomerPayment = txtCash.Value
ListItem = Me.LstItem.List


Dim rsho As Worksheet
Set rsho = ThisWorkbook.Sheets("OrderDataBase")
Dim nextRow As Integer
nextRow = rsho.Range("A" & Rows.Count).End(xlUp).Row + 1

On Error Resume Next
rsho.Range("A" & nextRow).Value = Now()
rsho.Range("C" & nextRow).Value = CustomerName
rsho.Range("D" & nextRow).Value = CustomerMobile
rsho.Range("E" & nextRow).Value = CustomerEmail
rsho.Range("F" & nextRow).Value = CustomerAddress
rsho.Range("G" & nextRow).Value = TransactionType
rsho.Range("H" & nextRow).Value = PaymentType
rsho.Range("I" & nextRow).Value = Subtotal
rsho.Range("J" & nextRow).Value = Discount
rsho.Range("K" & nextRow).Value = Total
rsho.Range("L" & nextRow).Value = CustomerPayment
rsho.Range("O" & nextRow).Resize(UBound(ListItem) + 1, UBound(ListItem, 1)).Value = ListItem

txtTransactionType.Text = ""
LstDisplay.Clear
LstItem.Clear
txtCash.Value = ""
txtSubtotal.Text = ""
lblItemCo.Caption = ""
txtbName.Text = ""
txtbMobile.Text = ""
txtbEmail.Text = ""
txtbAddress.Text = ""
txtSubtotal = ""
txtTax = ""
txtTotal = ""
txtcboPayment.Text = ""
lblOrderTime = ""
CustomerPayment = ""
发布评论

评论列表(0)

  1. 暂无评论