Jens Stenzeman
Jens Stenzeman

Reputation: 5

Why ActiveSheet.Cells() don't work?

I'am working on a VBA Module that reads Cells from a column of the active Workbook - the Output of an other Tool -, nothing spectecular, but it seems that I missed something. The Solutions of similar Questions I read and tested them, but without any luck. Get Value from a cell on a worksheet or Gather Cells and write it in Active Worksheet Here the Code until it throws "1004"

Dim FileName As String
Dim FileNameArray() As String
Dim VideoDataArray() As String
Dim TempString As String
Dim strPattern As String

Dim mot_H As Integer
Dim vok_H As Integer
Dim aufgest_H As Integer
Dim mot_S As Integer
Dim vok_S As Integer
Dim vis_Q As Integer
Dim aud_Q As Integer
Dim int_E As Integer
Dim i As Integer

'Nehme den Dateinamen
FileName = ActiveWorkbook.FullName
Debug.Print FileName

'Zerlege den Dateinamen
FileNameArray() = Split(FileName, "_")

'Fülle ein Array mit den Daten
    For i = 0 To 50

    Dim s As String
    s = ActiveSheet.Cells(i, 1).Value
    TempString = TempString & "_" & s & "_"

    Next i

I am sure it is only a trivial failure, but I can't find it at the Moment. Thank you very much!

Upvotes: 0

Views: 12431

Answers (1)

arcadeprecinct
arcadeprecinct

Reputation: 3777

The rows start at 1, not 0 so you'll get an error when you're trying to access .Cells(0,1). Start your i at 1 and it should be fine:

For i = 1 To 50
    '...
Next i

Upvotes: 7

Related Questions