本帖最后由 tcpuuu 于 2012-7-26 21:41 编辑
Private Sub Worksheet_Change(ByVal Target As Range)
If Application.Intersect(Target, [A2:R2]) Is Nothing Then Exit Sub
Dim myPath As String
myPath = ThisWorkbook.Path
Open myPath & "\ABC.INI" For Output As #1
Print #1, "[ABC]"
Print #1, "1=" & Trim([A2])
Print #1, "2=" & Trim([B2])
Print #1, "3=" & Trim([C2])
Print #1, "4=" & Trim([D2])
Print #1, "5=" & Trim([E2])
Print #1, "6=" & Trim([F2])
Print #1, "7=" & Trim([G2])
Print #1, "8=" & Trim([H2])
Print #1, "9=" & Trim([I2])
Print #1, "20=" & Trim([J2])
Print #1, "11=" & Trim([K2])
Print #1, "12=" & Trim([L2])
Print #1, "13=" & Trim([M2])
Print #1, "14=" & Trim([N2])
Print #1, "15=" & Trim([O2])
Print #1, "16=" & Trim([P2])
Print #1, "17=" & Trim([Q2])
Print #1, "18=" & Trim([R2])
Close #1
End Sub
=============================
請問 kevinch (excel VBA) 1= 到 18= 這段寫成 用 循環的(怎麼寫?)
for $i = 1 to 18
next
========================
我會了,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, AU3 比較簡單易懂
For i = 1 To 18
Print #1, i & "=" & Trim(Cells(2, i))
Next |