0
이 질문에 여러 번 대답했지만 이전에는 무엇이 잘못되었는지 알 수 없습니다.Excel 1004 런타임 오류
Option Explicit
Private Sub CommandButton1_Click()
Dim FileNum As Integer ' file num
Dim DataLine As String ' line of file
Dim entry() As String ' split line
Sheets("Sheet1").Select
ActiveSheet.Unprotect
Dim X_ As Integer ' cell x
X_ = 0
Dim Y_ As Integer ' cell y
Y_ = 0
Dim s As Variant
FileNum = FreeFile() ' create a free file
Open "C:\Users\vittorio\PycharmProjects\Fiddleheads\data.csv" For Input As #FileNum ' open the file
While Not EOF(FileNum)
Line Input #FileNum, DataLine ' read in data 1 line at a time
'MsgBox (DataLine)
entry = Split(DataLine, ",")
For Each s In entry
ActiveSheet.Cells(X_, Y_).Select
X_ = X_ + 1
Next s
X_ = 0
Y_ = Y_ + 1
Wend
End Sub
ActiveSheet.Cells(1, 1).Select
를 사용하여 나는 아무 문제가 없습니다. 하지만 Cells(1, 1)
에 대한 변수를 바꿀 때 오류가 발생합니다. 왜 그런지 알아?
재미 있군요, 실제로 이것에 대한 dup 응답이 있습니다 : http://stackoverflow.com/a/14650140/2258 –
왜 삶이 재밌는 또 다른 이유. 0을 기준으로하면 Excel로 변환 할 수없는 이유는 무엇입니까? – Mozzie
대신 'Offset()'을 사용할 수 있습니다. 그러나 Excel은 이러한 측면에서 괴상한 표현입니다. –