Page 1 of 1

อยากทราบวิธี update ข้อมูลไปยัง cell ที่ Vlookup/Matchได้ค่ะ

Posted: Tue Sep 30, 2014 11:00 pm
by jilux
ต้องการ update ข้อมูลไปยัง Cell ที่ เราคีย์code ขึ้นมา ซึ่งอยู่ต่าง sheet กันค่ะ
ลองเชียน VB แบบนี้ แต่ กลับขึ้น Sub or function not defined ค่ะ
ไม่ทราบว่าเขียน code ผิด หรือ ต้องแก้ไขอย่างไรคะ

Code: Select all

Dim DrugRange As Range
    Dim LotRange As Range
    Dim FillLot As Range
    Dim i As Range
    Set DrugRange = Range("List!B:F")
    Set LotRange = Range("List!F:F")
    Set FillLotRange = Range("FillForm!C8")
    i = Application.WorksheetFunction.Index(DrugRange, Match(FillLotRange, LotRange, 0))
    With Sheets("List")
        .Range("i").Value = _
            Sheets("FillForm").Range("C12").Value
    End With

Re: อยากทราบวิธี update ข้อมูลไปยัง cell ที่ Vlookup/Matchได

Posted: Tue Sep 30, 2014 11:28 pm
by snasui
:D ตัวอย่างการปรับ Code ครับ

Code: Select all

On Error Resume Next
Dim FillLotRange As Range
Dim LotRange As Range
Dim i As Range
Set LotRange = Range("List!B:B")
Set FillLotRange = Range("FillForm!C8")
With Application.WorksheetFunction
    Set i = Sheets("List").Range("F" & .Match(FillLotRange, LotRange, 0))
End With
With Sheets("List")
    i.Value = Sheets("FillForm").Range("C12").Value
End With

Re: อยากทราบวิธี update ข้อมูลไปยัง cell ที่ Vlookup/Matchได

Posted: Tue Sep 30, 2014 11:38 pm
by jilux
แก้ไขแล้วใช้ได้เยี่ยมเลยค่ะ ขอบคุณมากนะคะ :thup: :thup: :thup:

Re: อยากทราบวิธี update ข้อมูลไปยัง cell ที่ Vlookup/Matchได

Posted: Sat Oct 04, 2014 3:54 pm
by jilux
สอบถามเพิ่มเติมค่ะ
ถ้าต้องการให้ข้อมูล update ทั้งแถวเลย จะต้องแก้สูตรอย่างไรคะ

Code: Select all

On Error Resume Next
Dim FillCodeRange As Range
Dim CodeRange As Range
Dim i As Range
Set CodeRange = Range("List!B:B")
Set FillCodeRange = Range("FillForm!C8")
With Application.WorksheetFunction
    Set i = Sheets("List").Range("C:F" & .Match(FillCodeRange, CodeRange, 0))
End With
With Sheets("List")
    i.Value = Sheets("FillForm").Range("c4:f4").Value
End With
ลองเป็นแบบนี้มันใช้ไม่ได้ค่ะ :|

Re: อยากทราบวิธี update ข้อมูลไปยัง cell ที่ Vlookup/Matchได

Posted: Sat Oct 04, 2014 4:02 pm
by snasui
:D ตัวอย่างการปรับ Code ตามด้านล่างครับ

Code: Select all

'Other code
Dim i As Integer
Set CodeRange = Range("List!B:B")
Set FillCodeRange = Range("FillForm!C8")
With Application.WorksheetFunction
     i = .Match(FillCodeRange, CodeRange, 0)
End With
With Sheets("List")
    .Range("c" & i).Resize(1, 4).Value = Sheets("FillForm").Range("c4:f4").Value
End With
'Other code

Re: อยากทราบวิธี update ข้อมูลไปยัง cell ที่ Vlookup/Matchได

Posted: Sat Oct 04, 2014 4:15 pm
by jilux
ปรับแล้วใช้ได้ค่ะ ขอบคุณมากนะคะ