ผมสร้าง form -item_holdingbuy มา เมื่อกรอกข้อมูลเสร็จ การบันทึกจะทำ 2 งานคือ
1 วางข้อมูลใน textbox ข้างล่าง ให้มีการเรียงกันตามหัวข้อ แต่ละหัวข้อ ขึ้นบรรทัดใหม่ (แต่มันไม่ขึ้นบรรทัดให้แต่แสดงสัญลักษณ์แปลกๆ)
แต่ตอนนำข้อมูลใส่ใน sheet holdingbuy กลับเว้นบรรทัดได้ถูกต้อง
2 ให้ระบค้นหาชื่อ B3-AZ3 ใน sheet holdingbuy ว่ามีชื่อตรงกับ drop down -Cboitem- ใน form item_holdingbuy หรือไม่ ถ้าเจอ ให้ใส่ข้อมูลใน text box ข้างล่าง ในตรง colunm เดียวกับ สินค้า
ประด็นคือ มันสามารถค้นได้ถูกต้องแล้ว แต่ผมไม่รู้วิธีทำให้วางข้อมูลใน textbox ให้ตรงกับชื่อ สินค้าใน sheet holdingbuy ในตำแหน่งที่ถูกต้อง ระหว่าง B43:AZ43 ครับ
Code: Select all
Private Sub CommandButton1_Click()
TextBox7.Text = "»Õ§º»ÃÐÁÒ³" & " " & b_yrs _
& Chr(10) & "ñ." & " " & Cboitem.Value & "/" & Cbocompany01.Value & " " & "ÃÒ¤Ò" & " " & price01.Value _
& Chr(10) & "ò." & " " & Cbocompany02.Value & "/" & "ÃÒ¤Ò" & " " & price02.Value _
& Chr(10) & "ó." & " " & Cbocompany03.Value & "/" & "ÃÒ¤Ò" & " " & price03.Value _
Dim FindString As String
Dim Rng As Range
FindString = Cboitem.Value
'FindString = InputBox("Enter a Search value")
If Trim(FindString) <> "" Then
With Sheets("holdingBuy").Range("B3:AZ3")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
MsgBox "ok found"
'----------------- how to insert data to correct range
Worksheets("holdingBuy").Range("F43").Value = TextBox7.Value
Else
MsgBox "Nothing found"
End If
End With
End If
You do not have the required permissions to view the files attached to this post.