Find, select, cut and paste

  • Thread starter Thread starter Subenemi
  • Start date Start date
S

Subenemi

Hello

I am completely new to excel programming and I would like some help if
possible.
I have a spreadsheet with some logging information. I am trying to get
the text split when I found the string "Initializing server", which
can happens many times.
So basically, I need to create new sheets every time I found this
string, copying all the content found until it reaches the row with
that string to the new sheet.
Here is a piece of the log file:

| 2008-06-16 13:34:22.916 | 71212 | ArsInit | 101 | Initializing
server | 3
| 2008-06-16 13:34:22.948 | 71212 | ReqLoop | 201 | Entering Request
1 | 1
| 2008-06-16 13:34:22.948 | 71212 | ReqLoop | 227 | Received
Scriptname: /scripts/adess.dll | 1
| 2008-06-16 13:34:22.948 | 71212 | ReqLoop | 213 | Reading GET
request | 1
| 2008-06-16 13:35:01.462 | 71212 | ArsInit | 101 | Initializing
server | 3
| 2008-06-16 13:35:01.477 | 71212 | ReqLoop | 231 | Creating request
| 1
| 2008-06-16 13:35:01.477 | 71212 | ReqLoop | 219 | Created request
| 1
| 2008-06-16 13:35:01.477 | 71212 | ReqLoop | 235 | Request: service
= GetPollingDelay | 1
| 2008-06-16 13:35:01.477 | 71212 | ReqLoop | 235 | Request:
connectionKey = | 1

On this case, the result should be two sheets, one with this info

| 2008-06-16 13:34:22.948 | 71212 | ReqLoop | 201 | Entering Request
1 | 1
| 2008-06-16 13:34:22.948 | 71212 | ReqLoop | 227 | Received
Scriptname: /scripts/adess.dll | 1
| 2008-06-16 13:34:22.948 | 71212 | ReqLoop | 213 | Reading GET
request | 1

and another one with this

| 2008-06-16 13:35:01.477 | 71212 | ReqLoop | 231 | Creating request
| 1
| 2008-06-16 13:35:01.477 | 71212 | ReqLoop | 219 | Created request
| 1
| 2008-06-16 13:35:01.477 | 71212 | ReqLoop | 235 | Request: service
= GetPollingDelay | 1
| 2008-06-16 13:35:01.477 | 71212 | ReqLoop | 235 | Request:
connectionKey = | 1

Is is possible to help me?
 
Not sure why my previous answer didn't get posted

Sub splitSheet()

InitStr = UCase("Initializing server")
With Sheets("Sheet1")
RowCount = 1
FirstRow = RowCount

Do While .Range("A" & RowCount) <> ""
StrPos = InStr(UCase(.Range("A" & RowCount)), InitStr)
If .Range("A" & (RowCount + 1)) = "" Or StrPos > 0 Then

If StrPos > 0 Then
LastRow = RowCount - 1
Else
LastRow = RowCount
End If

If LastRow <> 0 Then
Set newsht = Worksheets.Add(after:=Sheets(Sheets.Count))
.Rows(FirstRow & ":" & LastRow).Copy _
Destination:=newsht.Rows(1)
End If
FirstRow = RowCount + 1
End If
RowCount = RowCount + 1
Loop
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top