Re: รบกวนช่วยตรวจสูตรครับ
Posted: Sun Oct 15, 2017 12:29 pm
หมายถึงจากคอลัมน์ S ให้วิ่งไปทางซ้ายและไปหยุดที่เซลล์แรกที่มีข้อมูลครับyangkodza wrote:รบกวนอาจาร์ยอธิบาย
cells(8,"S").end(xltoleft)
"S" หมายถึงอะไรครับ
ฟอรัม Excel, VBA และอื่นๆ ของคนไทยเพื่อประโยชน์ของทุกคนในจักรวาล (Forum Excel, VBA and others of Thai people for everyone in the universe.)
http://snasui.com/
หมายถึงจากคอลัมน์ S ให้วิ่งไปทางซ้ายและไปหยุดที่เซลล์แรกที่มีข้อมูลครับyangkodza wrote:รบกวนอาจาร์ยอธิบาย
cells(8,"S").end(xltoleft)
"S" หมายถึงอะไรครับ
Code: Select all
Sub ว่ายน้ำ()
Dim lstCol As String
lstCol = Cells(8, "x").End(xlToLeft).Address(0, 0)
Range("lstCol").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("AS8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AS8").Select
End Sub
Range("lstCol").Select
ก็ไม่ได้Code: Select all
'Other code
Dim sb As Workbook, sbc As String
'Other code
Do Until fileName = ""
Select Case fileName
Case "02สุขศึกษา_ป" & classroom1 & ".xlsm"
Set sb = Workbooks.Open(CurrDir & "\" & fileName)
sbc = sb.Worksheets("C2T1").Cells(8, "y").End(xlToLeft).Address(0, 0)
sb.Close savechanges:=False
' lstCol = Cells(7, Columns.Count).End(xlToLeft).Address(0, 0)
Range("l4").Resize(50, 1).Formula = "='" & CurrDir & "\[" & fileName & "]C2T1'!" & sbc
End Select
fileName = Dir()
Loop
'Other code
สมบูรณ์แบบแล้วครับsnasui wrote: ตัวอย่างการปรับ Code ซึ่งต้องเขียนที่ไฟล์ปลายทาง ไม่ใช้ต้นทาง เป็นการเปิดไฟล์ต้นทางเพื่อหาตำแหน่งเสียก่อน ได้ตำแหน่งมาแล้วค่อยปิดไฟล์ต้นทางครับ
Code: Select all
'Other code Dim sb As Workbook, sbc As String 'Other code Do Until fileName = "" Select Case fileName Case "02สุขศึกษา_ป" & classroom1 & ".xlsm" Set sb = Workbooks.Open(CurrDir & "\" & fileName) sbc = sb.Worksheets("C2T1").Cells(8, "y").End(xlToLeft).Address(0, 0) sb.Close savechanges:=False ' lstCol = Cells(7, Columns.Count).End(xlToLeft).Address(0, 0) Range("l4").Resize(50, 1).Formula = "='" & CurrDir & "\[" & fileName & "]C2T1'!" & sbc End Select fileName = Dir() Loop 'Other code