Page 1 of 1
ขอโค้ด VBA
Posted: Wed Aug 26, 2015 4:22 pm
by nopparuj
เรียน ท่านผู้รู้
ผมเขียน VBA ให้เริ่มต้นบรรทัดใหม่ โดยที่ผมเขียนจะเริ่มบรรทัดที่ 1 แต่อยากให้เริ่มใหม่ บรรทัดที่ 3 แต่ผมไม่ทราบว่าจะเปลี่ยนตรงไหน รบกวนแนะนำเพิ่มเติมด้วยครับ
Re: ขอโค้ด VBA
Posted: Wed Aug 26, 2015 4:32 pm
by nopparuj
Code: Select all
Private Sub worksheet_change(ByVal target As Range)
target.Offset(1, 0).Activate
End Sub
Private Sub worksheet_selectionchange(ByVal target As Range)
If target.Row = 36 Then
target.Offset(0, 1).End(xlUp).Activate
End If
End Sub
Re: ขอโค้ด VBA
Posted: Wed Aug 26, 2015 4:33 pm
by nopparuj
ต้องขออภัยที่ลืมแนบโค้ดมาให้ด้วย
ตอนนี้แนบมาให้แล้วครับ
Re: ขอโค้ด VBA
Posted: Wed Aug 26, 2015 6:06 pm
by snasui

ตัวอย่างการปรับ Code ครับ
Code: Select all
Private Sub worksheet_selectionchange(ByVal target As Range)
If target.Row = 41 Then
Cells(3, target.Column).Select
End If
End Sub
Re: ขอโค้ด VBA
Posted: Wed Aug 26, 2015 6:58 pm
by nopparuj
Code: Select all
Private Sub worksheet_change(ByVal target As Range)
target.Offset(1, 0).Activate
End Sub
Private Sub worksheet_selectionchange(ByVal target As Range)
If target.Row = 41 Then
Cells(3, target.Column).Select
End If
End Sub
โค้ดที่อาจารย์ที่อาจารย์ปรับมาให้ ใช้งานได้ครับ แต่หากต้องการให้ขยับไปในคอลัมน์ ต่อๆไปครับ ควรปรับตรงไหนครับ เช่น เมื่อถึง บรรทัดที่ 41 คอลัมน์ A ก็ให้ไปที่บรรทัดที่ 3 คอลัมน์ B ครับ
Re: ขอโค้ด VBA
Posted: Wed Aug 26, 2015 7:00 pm
by snasui
nopparuj wrote:เช่น เมื่อถึง บรรทัดที่ 41 คอลัมน์ A ก็ให้ไปที่บรรทัดที่ 3 คอลัมน์ B ครับ

ตัวอย่างการปรับ Code ครับ
Code: Select all
Cells(3, target.offset(0,1).Column).Select
Re: ขอโค้ด VBA
Posted: Wed Aug 26, 2015 7:06 pm
by nopparuj
เรียน อาจารย์
โค้ดที่ปรับ เอามาใช้แล้วได้ตามความประสงค์ครับ
ขอขอบพระคุณอย่างสูง