 |
|
สวัสดีคะ ตอนนี้ติดปัญหาคะ
คืออยากได้โค้ด ที่ใช้คำสั่งวน ไป column ถัดไป
ซึ่งตอนนี้ใช้
If target.Address = Range("$E$18").Address Then

ต้องการคำสั่งที่ วนใช้ Column ถัดไป คือ E เเล้วต่อไป เป็น F ,G, H,I
ตามที่กำหนด รบกวนหน่อยคะ
Code ตามด้านล่างคะ
Sub worksheet_change(ByVal target As Range)
If target.Address = Range("$E$18").Address Then
Dim lot As String
lot = Range("E18:E18").Value
If Len(lot) <= 0 Then
Exit Sub
End If
Dim a As String
Dim x As String
a = getLotabc(x)
x = Range("E18:E18").Value
Call ShowMFGDate(lot)
End If
If target.Address = Range("$E$18:$I$18").Address Then
If UCase(target.Value) = UCase(Range("E39:E39").Value) Then
Range("E18:E18").Value = lot
End If
End If
End Sub
Function ConvertDate(lot As String) As Date
Dim nyear As Integer
Dim nmonth As Integer
Dim nday As Integer
Dim sTmp As String
sTmp = Mid(CStr(VBA.Year(Now())), 1, 3)
nyear = CInt(sTmp & Mid(lot, 1, 1))
sTmp = Mid(UCase(lot), 2, 1)
Select Case sTmp
Case "X"
nmonth = 10
Case "Y"
nmonth = 11
Case "Z"
nmonth = 12
Case Else
nmonth = CInt(sTmp)
End Select
nday = CInt(Mid(lot, 3, 2))
Dim dt As Date
dt = DateSerial(nyear, nmonth, nday)
ConvertDate = dt
End Function
Sub ShowMFGDate(lot As String)
Dim showlot As String
showlot = Range("E18:E18").Value
If UCase(showlot) = "NO" Then
Range("E18:E18").Value = showlot
Exit Sub
End If
Dim dt As Date
dt = ConvertDate(showlot)
Range("E39:E39").Value = dt
dt = Range("E39:E39")
lot = Range("E39:E39")
Range("E39:E39").Value = Format(dt, "dd-MMM-YY")
End Sub
Function getLotabc(x As String)
Dim a As String
a = Range("E18:E18").Value
getLotabc = a
End Function
Tag : .NET, Ms Access, Excel (Excel.Application)
|
|
 |
 |
 |
 |
Date :
2018-10-11 11:53:23 |
By :
S-Hyun |
View :
2425 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |