Searching for a string and move it's data to different sheets

xboon_95

New member
Joined
Jul 25, 2014
Messages
4
Reaction score
0
Points
0
Hi all,

I'm trying to import a .txt file to Excel and the program will filter a string called "¯ Starting Leak Checking(negative pressure)..." in column A only, and once it is found, the program will move this string onwards to the next sheet. For instance, the data is shown below :

¯ Starting Leak Checking(negative pressure)...

00:00:00 00:00:01 L -86 1 115
00:00:00 00:00:02 L -80 2 123
00:00:00 00:00:03 L -90 2 122
00:00:00 00:00:04 O -98 2 156
00:00:00 00:00:05 P -104 2 135
00:00:00 00:00:06 L 5 1 453
00:00:00 00:00:07 L 10 2 123

¯ Starting Leak Checking(negative pressure)...

00:00:01 00:00:01 L -87 1 117
00:00:02 00:00:02 P -86 1 154
00:00:03 00:00:03 O -91 2 167
00:00:04 00:00:04 O -98 2 156
00:00:05 00:00:05 P -104 2 135
00:00:06 00:00:06 L 7 1 453
00:00:07 00:00:07 L 10 2 127

¯ Starting Leak Checking(negative pressure)...
00:00:08 00:00:01 L -87 1 117
00:00:09 00:00:02 P -86 1 154
00:00:10 00:00:03 O -91 2 167
00:00:11 00:00:04 O -98 2 156
00:00:12 00:00:05 P -104 2 135
00:00:13 00:00:06 L 7 1 453
00:00:14 00:00:07 L 10 2 127

¯ Starting Leak Checking(negative pressure)...
00:00:15 00:00:01 L -87 1 117
00:00:16 00:00:02 P -86 1 154
00:00:17 00:00:03 O -91 2 167
00:00:18 00:00:04 O -98 2 156
00:00:19 00:00:05 P -104 2 135
00:00:20 00:00:06 L 7 1 453
00:00:21 00:00:07 L 10 2 127

Since there are 4 strings of "¯ Starting Leak Checking(negative pressure)...", what I'm trying to achieve now is to move these data into 4 different sheets, with the first string of "¯ Starting Leak Checking(negative pressure)..." and it's data in the first sheet, second string of "¯ Starting Leak Checking(negative pressure)..." in the second sheet and ultimately, there will be 4 different sheets. Is it possible to do this? Any help will be appreciated. I tried the code below but it doesn't work.

Code:
Dim c As Range, i As Long
    Dim firstAddress As String
    i = 1
    With Range("A1:Q18215")
        Set c = .Find("Dim c As Range, i As Long    Dim firstAddress As String
    i = 1
    With Range("A1:Q18215")
        Set c = .Find("» Starting Leak Checking(negative pressure)...")
        If Not c Is Nothing Then
            firstAddress = c.Address
            Do
                .Range(c, c.End(xlDown)).Copy Sheets("sheet" & i).Range("A1:Q18215")
                i = i + 1
                Set c = .FindNext(c)
            Loop Until c.Address = firstAddress
        End If
    End With")
        If Not c Is Nothing Then
            firstAddress = c.Address
            Do
                .Range(c, c.End(xlDown)).Copy Sheets("sheet" & i).Range("A1:Q18215")
                i = i + 1
                Set c = .FindNext(c)
            Loop Until c.Address = firstAddress
        End If
    End With
 
renaming sheets

Cross-posted at VBAExpress

Hey dude, yeah. I posted in more than 1 forums. The problem is almost solved, just that throughout my calculation of codes, i assigned the sheet value as "Sheet1". Any idea how do i rename the sheets or the activesheets so that i could calculate for the rest of the sheets too? Any help is appreciated, thank you.
 
Back
Top