The way you call SplitFields seems to be correct. You can also use:
Sub Test2()
Call SplitFields
End Sub
but that doesn't cause the run-time error.
I'm not sure, but maybe it's because I run Excel 2000.
"juser69" <(E-Mail Removed)> schreef in bericht
news:4664291e$0$6532$(E-Mail Removed)...
>I get:
>
> Run-time error '1004':
>
> Select method of Range class failed
>
> On line 29 "ws.Rows("1:1").Select"
>
> I know I am probably doing something wrong, but I can't
> figure it out yet. Maybe the way I am calling your
> routines? I have yet to figure out how one sub can call
> another, especially in a different module, so far, not
> even in the same module :-)
>
> '-------------------------------------------------
> Attribute VB_Name = "Test2"
> Option Explicit
> Private Type DataFields
> f_Server As String
> f_Path As String
> f_Hotfix As String
> f_Date As String
> f_Time As String
> f_KBytes As String
> End Type
>
> Sub Test2()
>
> SplitFields
>
> End Sub
>
>
>
> Private Sub SplitFields()
> Dim wb As Workbook
> Dim ws As Worksheet
> Dim LastRow, r, l, i, j, k As Integer
> Dim txtLine As String
> Dim DATA As DataFields
> Set wb = ThisWorkbook
> Set ws = wb.Sheets(1)
> ws.Activate
> ws.Rows("1:1").Select
> Selection.Insert Shift:=xlDown
> ws.Cells(1, 9).Value = "Server"
> ws.Cells(1, 10).Value = "Path"
> ws.Cells(1, 11).Value = "Hotfix"
> ws.Cells(1, 12).Value = "Date"
> ws.Cells(1, 13).Value = "Time"
> ws.Cells(1, 14).Value = "Kilobytes"
> ws.Cells(65536, 1).Select
> Selection.End(xlUp).Select
> LastRow = ActiveCell.Row
> i = 0: j = 1
> ClearFields DATA
> For r = 2 To LastRow Step 1
> txtLine = ws.Cells(r, 1).Value
> l = Len(txtLine)
> If txtLine <> Empty Then
> k = InStr(1, txtLine, Chr(44), vbTextCompare)
> DATA.f_Server = Left(txtLine, (k - 1))
> txtLine = Right(txtLine, (l - k))
> l = Len(txtLine)
> k = InStr(1, txtLine, Chr(44), vbTextCompare)
> DATA.f_Path = Left(txtLine, (k - 1))
> txtLine = Right(txtLine, (l - k))
> l = Len(txtLine)
> k = InStr(1, txtLine, Chr(44), vbTextCompare)
> DATA.f_Hotfix = Left(txtLine, (k - 1))
> txtLine = Right(txtLine, (l - k))
> l = Len(txtLine)
> k = InStr(1, txtLine, Chr(32), vbTextCompare)
> DATA.f_Date = Left(txtLine, (k - 1))
> txtLine = Right(txtLine, (l - k))
> l = Len(txtLine)
> k = InStr(1, txtLine, Chr(44), vbTextCompare)
> DATA.f_Time = Left(txtLine, (k - 1))
> DATA.f_KBytes = Right(txtLine, (l - k))
> ws.Cells(r, 9).Value = DATA.f_Server
> ws.Cells(r, 10).Value = DATA.f_Path
> ws.Cells(r, 11).Value = DATA.f_Hotfix
> ws.Cells(r, 12).Value = DATA.f_Date
> ws.Cells(r, 13).Value = DATA.f_Time
> ws.Cells(r, 14).Value = DATA.f_KBytes
> ClearFields DATA
> End If
> Next r
> Set ws = Nothing
> Set wb = Nothing
> SortData (LastRow)
> End Sub
>
> Private Sub ClearFields(d As DataFields)
> d.f_Server = vbNullString
> d.f_Path = vbNullString
> d.f_Hotfix = vbNullString
> d.f_Date = vbNullString
> d.f_Time = vbNullString
> d.f_KBytes = vbNullString
> End Sub
>
> Private Sub SortData(lr As Integer)
> Dim wb As Workbook
> Dim ws As Worksheet
> Dim r, k, c As Integer
> Set wb = ThisWorkbook
> Set ws = wb.Sheets(1)
> r = 2
> ws.Cells(r, 9).Select
> While r < lr
> Range(Selection, Selection.End(xlDown)).Select
> k = Selection.Count - 1
> Range("I" & r & ":N" & (r + k)).Select
> Selection.Sort Key1:=Range("L" & r), Order1:
> =xlAscending, Key2:=Range("M" & r) _
> , Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
> MatchCase:=False, _
> Orientation:=xlTopToBottom
> r = r + k + 2
> ws.Cells(r, 9).Select
> Wend
> Set ws = Nothing
> Set wb = Nothing
> End Sub
> '-------------------------------------------------
>
>
>