Splitting Random Data

Brentsa

Board Regular
Joined
Oct 3, 2013
Messages
118
Office Version
  1. 365
Platform
  1. Windows
Good day I have a excel sheet that have data in Column A-N. The data in rows represents various transactions. To split the transactions the new transaction starts with "Source" in Column A.

Now as each transaction has it's own makeup, there is no definite number of lines between each transaction, to explain the first 5 times that the word "Source" Appears in column A is at Line 2, 17, 24, 37, 43. Also this sequence will change each day.

I am looking for a way to split each transaction, so that I could filter the results easier.

As there is a lot of personal info I cannot post the original spreadsheet.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
As there is a lot of personal info I cannot post the original spreadsheet.
.. but of course you could easily disguise that personal info or make up some dummy data and provide that and the expected results with XL2BB?
 
Upvote 0
Here is a copy and paste of the document with all info removed. What I am looking for a way to split each transaction, so that I could filter the results easier. Each transaction starts with "Source" in Column A and ends with "Total:"

Selected User:
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R10 Fit
R50 Fit
R100 Fit
R200 Fit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R200 Fit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R50 Fit
R100 Fit
R200 Fit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R10 Fit
R20 Fit
R50 Fit
R100 Fit
R200 Fit
R10 Unfit
R20 Unfit
R50 Unfit
R100 Unfit
R200 Unfit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R10 Fit
R20 Fit
R50 Fit
R100 Fit
R200 Fit
R10 Unfit
R20 Unfit
R50 Unfit
R100 Unfit
R200 Unfit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
10c
20c
50c
R1
R2
R5
Total:Transfer Status - Acknowledged
 
Upvote 0
Doing it manually I've been able to copy and paste each "Source" into a separate worksheet then using a variety of formulas I have been able to create a table as follows:

Transfer StatusSourceDestinationTotal:
Username:Area:Safe:Username:Area:Safe:
=VLOOKUP("Total: ",Sheet2!$A$2:$C$30,3,)=RIGHT(A3,LEN(A3)-SEARCH(" ",A3,SEARCH(" ",A3,SEARCH(" ",A3,1)+1)+1))=RIGHT(Sheet2!$E$1,LEN(Sheet2!$E$1)-SEARCH(" ",Sheet2!$E$1,1))=RIGHT(Sheet2!$G$1,LEN(Sheet2!$G$1)-SEARCH(" ",Sheet2!$G$1,1))=RIGHT(Sheet2!$I$1,LEN(Sheet2!$I$1)-SEARCH(" ",Sheet2!$I$1,1))=RIGHT(Sheet2!$F$1,LEN(Sheet2!$F$1)-SEARCH(" ",Sheet2!$F$1,1))=RIGHT(Sheet2!$H$1,LEN(Sheet2!$H$1)-SEARCH(" ",Sheet2!$H$1,1))=RIGHT(Sheet2!$J$1,LEN(Sheet2!$J$1)-SEARCH(" ",Sheet2!$J$1,1))=VLOOKUP("Total: ",Sheet2!$A$2:$B$30,2,)
=VLOOKUP("Total: ",Sheet3!$A$2:$C$30,3,)=RIGHT(A4,LEN(A4)-SEARCH(" ",A4,SEARCH(" ",A4,SEARCH(" ",A4,1)+1)+1))=RIGHT(Sheet3!$E$1,LEN(Sheet3!$E$1)-SEARCH(" ",Sheet3!$E$1,1))=RIGHT(Sheet3!$G$1,LEN(Sheet3!$G$1)-SEARCH(" ",Sheet3!$G$1,1))=RIGHT(Sheet3!$I$1,LEN(Sheet3!$I$1)-SEARCH(" ",Sheet3!$I$1,1))=RIGHT(Sheet3!$F$1,LEN(Sheet3!$F$1)-SEARCH(" ",Sheet3!$F$1,1))=RIGHT(Sheet3!$H$1,LEN(Sheet3!$H$1)-SEARCH(" ",Sheet3!$H$1,1))=RIGHT(Sheet3!$J$1,LEN(Sheet3!$J$1)-SEARCH(" ",Sheet3!$J$1,1))=VLOOKUP("Total: ",Sheet3!$A$2:$B$30,2,)
=VLOOKUP("Total: ",Sheet4!$A$2:$C$30,3,)=RIGHT(A5,LEN(A5)-SEARCH(" ",A5,SEARCH(" ",A5,SEARCH(" ",A5,1)+1)+1))=RIGHT(Sheet4!$E$1,LEN(Sheet4!$E$1)-SEARCH(" ",Sheet4!$E$1,1))=RIGHT(Sheet4!$G$1,LEN(Sheet4!$G$1)-SEARCH(" ",Sheet4!$G$1,1))=RIGHT(Sheet4!$I$1,LEN(Sheet4!$I$1)-SEARCH(" ",Sheet4!$I$1,1))=RIGHT(Sheet4!$F$1,LEN(Sheet4!$F$1)-SEARCH(" ",Sheet4!$F$1,1))=RIGHT(Sheet4!$H$1,LEN(Sheet4!$H$1)-SEARCH(" ",Sheet4!$H$1,1))=RIGHT(Sheet4!$J$1,LEN(Sheet4!$J$1)-SEARCH(" ",Sheet4!$J$1,1))=VLOOKUP("Total: ",Sheet4!$A$2:$B$30,2,)
=VLOOKUP("Total: ",Sheet5!$A$2:$C$30,3,)=RIGHT(A6,LEN(A6)-SEARCH(" ",A6,SEARCH(" ",A6,SEARCH(" ",A6,1)+1)+1))=RIGHT(Sheet5!$E$1,LEN(Sheet5!$E$1)-SEARCH(" ",Sheet5!$E$1,1))
=RIGHT(Sheet5!$G$1,LEN(Sheet5!$G$1)-SEARCH(" ",Sheet5!$G$1,1))
=RIGHT(Sheet5!$I$1,LEN(Sheet5!$I$1)-SEARCH(" ",Sheet5!$I$1,1))=RIGHT(Sheet5!$F$1,LEN(Sheet5!$F$1)-SEARCH(" ",Sheet5!$F$1,1))=RIGHT(Sheet5!$H$1,LEN(Sheet5!$H$1)-SEARCH(" ",Sheet5!$H$1,1))=RIGHT(Sheet5!$J$1,LEN(Sheet5!$J$1)-SEARCH(" ",Sheet5!$J$1,1))=VLOOKUP("Total: ",Sheet5!$A$2:$B$30,2,)

The process of creating new sheets to get to the table above has taken hours and I now have almost 150 sheets in workbook (which I've hidden), this in itself is not a issue I believe, as long as I can get the information in the above table. As I can now filter the information to what I need it for.
 
Upvote 0
Showing a bunch of formulas that relate to 150 sheets that we cannot see even one of doesn't show what actual results you would want from your sample data. :(
 
Upvote 0
Showing a bunch of formulas that relate to 150 sheets that we cannot see even one of doesn't show what actual results you would want from your sample data. :(
Ok in first post I've shown you what my Data looks like With Source being the start of each new transaction. I've manually captured each transaction by copy and paste into a new sheet.

Here is a copy and paste of the document with all info removed. What I am looking for a way to split each transaction, so that I could filter the results easier. Each transaction starts with "Source" in Column A and ends with "Total:"

Selected User:
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R10 Fit
R50 Fit
R100 Fit
R200 Fit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R200 Fit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R50 Fit
R100 Fit
R200 Fit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R10 Fit
R20 Fit
R50 Fit
R100 Fit
R200 Fit
R10 Unfit
R20 Unfit
R50 Unfit
R100 Unfit
R200 Unfit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
R10 Fit
R20 Fit
R50 Fit
R100 Fit
R200 Fit
R10 Unfit
R20 Unfit
R50 Unfit
R100 Unfit
R200 Unfit
Total:Transfer Status - Acknowledged
SourceDestinationInitiated by:Username:Username:Area:Area:Safe:Safe:Date/Time of Transfer:Date/Time of Acknowledgement:Transfer Make-up:
10c
20c
50c
R1
R2
R5
Total:Transfer Status - Acknowledged
So sheet 1 has line 2-7, Sheet 2 has line 8-10, Sheet 3 has line 11-15, Sheet 4 has line 16-27, Sheet 5 has line 28-39 and Sheet 6 has line 40-47. This was done manually through copy and paste.

Doing it manually I've been able to copy and paste each "Source" into a separate worksheet then using a variety of formulas I have been able to create a table as follows:

Transfer StatusSourceDestinationTotal:
Username:Area:Safe:Username:Area:Safe:
=VLOOKUP("Total: ",Sheet2!$A$2:$C$30,3,)=RIGHT(A3,LEN(A3)-SEARCH(" ",A3,SEARCH(" ",A3,SEARCH(" ",A3,1)+1)+1))=RIGHT(Sheet2!$E$1,LEN(Sheet2!$E$1)-SEARCH(" ",Sheet2!$E$1,1))=RIGHT(Sheet2!$G$1,LEN(Sheet2!$G$1)-SEARCH(" ",Sheet2!$G$1,1))=RIGHT(Sheet2!$I$1,LEN(Sheet2!$I$1)-SEARCH(" ",Sheet2!$I$1,1))=RIGHT(Sheet2!$F$1,LEN(Sheet2!$F$1)-SEARCH(" ",Sheet2!$F$1,1))=RIGHT(Sheet2!$H$1,LEN(Sheet2!$H$1)-SEARCH(" ",Sheet2!$H$1,1))=RIGHT(Sheet2!$J$1,LEN(Sheet2!$J$1)-SEARCH(" ",Sheet2!$J$1,1))=VLOOKUP("Total: ",Sheet2!$A$2:$B$30,2,)
=VLOOKUP("Total: ",Sheet3!$A$2:$C$30,3,)=RIGHT(A4,LEN(A4)-SEARCH(" ",A4,SEARCH(" ",A4,SEARCH(" ",A4,1)+1)+1))=RIGHT(Sheet3!$E$1,LEN(Sheet3!$E$1)-SEARCH(" ",Sheet3!$E$1,1))=RIGHT(Sheet3!$G$1,LEN(Sheet3!$G$1)-SEARCH(" ",Sheet3!$G$1,1))=RIGHT(Sheet3!$I$1,LEN(Sheet3!$I$1)-SEARCH(" ",Sheet3!$I$1,1))=RIGHT(Sheet3!$F$1,LEN(Sheet3!$F$1)-SEARCH(" ",Sheet3!$F$1,1))=RIGHT(Sheet3!$H$1,LEN(Sheet3!$H$1)-SEARCH(" ",Sheet3!$H$1,1))=RIGHT(Sheet3!$J$1,LEN(Sheet3!$J$1)-SEARCH(" ",Sheet3!$J$1,1))=VLOOKUP("Total: ",Sheet3!$A$2:$B$30,2,)
=VLOOKUP("Total: ",Sheet4!$A$2:$C$30,3,)=RIGHT(A5,LEN(A5)-SEARCH(" ",A5,SEARCH(" ",A5,SEARCH(" ",A5,1)+1)+1))=RIGHT(Sheet4!$E$1,LEN(Sheet4!$E$1)-SEARCH(" ",Sheet4!$E$1,1))=RIGHT(Sheet4!$G$1,LEN(Sheet4!$G$1)-SEARCH(" ",Sheet4!$G$1,1))=RIGHT(Sheet4!$I$1,LEN(Sheet4!$I$1)-SEARCH(" ",Sheet4!$I$1,1))=RIGHT(Sheet4!$F$1,LEN(Sheet4!$F$1)-SEARCH(" ",Sheet4!$F$1,1))=RIGHT(Sheet4!$H$1,LEN(Sheet4!$H$1)-SEARCH(" ",Sheet4!$H$1,1))=RIGHT(Sheet4!$J$1,LEN(Sheet4!$J$1)-SEARCH(" ",Sheet4!$J$1,1))=VLOOKUP("Total: ",Sheet4!$A$2:$B$30,2,)
=VLOOKUP("Total: ",Sheet5!$A$2:$C$30,3,)=RIGHT(A6,LEN(A6)-SEARCH(" ",A6,SEARCH(" ",A6,SEARCH(" ",A6,1)+1)+1))=RIGHT(Sheet5!$E$1,LEN(Sheet5!$E$1)-SEARCH(" ",Sheet5!$E$1,1))
=RIGHT(Sheet5!$G$1,LEN(Sheet5!$G$1)-SEARCH(" ",Sheet5!$G$1,1))
=RIGHT(Sheet5!$I$1,LEN(Sheet5!$I$1)-SEARCH(" ",Sheet5!$I$1,1))=RIGHT(Sheet5!$F$1,LEN(Sheet5!$F$1)-SEARCH(" ",Sheet5!$F$1,1))=RIGHT(Sheet5!$H$1,LEN(Sheet5!$H$1)-SEARCH(" ",Sheet5!$H$1,1))=RIGHT(Sheet5!$J$1,LEN(Sheet5!$J$1)-SEARCH(" ",Sheet5!$J$1,1))=VLOOKUP("Total: ",Sheet5!$A$2:$B$30,2,)

The process of creating new sheets to get to the table above has taken hours and I now have almost 150 sheets in workbook (which I've hidden), this in itself is not a issue I believe, as long as I can get the information in the above table. As I can now filter the information to what I need it for.
The result I'm looking for is based on the individual transactions, which I've copied and pasted each transaction onto a new sheet.

Column A looks for where "Total: " appears and then gives me the results of the 3rd column: Transfer Status - Acknowledged
As I only need to know Acknowledged or Reject Status Column B I've asked for it to only give me the last word of column A: Acknowledged
Coloumn C - E tells me What is the source of the transaction so I used the formula similar to Column B to give only the results. The data in the sheet has Colum E: "Username: Brenton"; Column G: "Area: Sales" and Column I: "Safe: Magnum" So the result will give name only.
Column F - H Is the safe as Column C- E except this is the destination. The data in the sheet has Colum E: "Username: Brenton"; Column G: "Area: " and Column I: "Safe: " So the result will give name only. The result can be blank.
Column G looks for where "Total: " appears and then gives me the results of the 2rd column: Amount "10.00"

Transfer StatusSourceDestinationTotal:
Username:Area:Safe:Username:Area:Safe:
Transfer Status - AcknowledgedAcknowledgedBrentonSalesMagnumMUNROE10.00

I hope this helps.....

I want the quickest method to get to the last step as this will be a daily document and thus cannot spend hours copying and pasting.
 
Upvote 0
I want the quickest method to get to the last step
OK, that will not involve creating 150 (or whatever) new worksheets and the formulas that you are currently using. But your last post appears to show one transaction when the original sample seems to have 6. Your one result also includes text that does not appear in your original sample which is making it very hard to understand exactly what is required.

Could you please make up some dummy data for, say, three varied transactions and give us that and the full expected results from those three transactions so that we can clearly see the starting point and the end point for data that we are not familiar with?

The quickest method I believe will be to use a macro. Is that acceptable?
 
Upvote 0
Data:
Selected User:ALL
SourceDestinationInitiated by:Username: BrentonUsername: JaneArea: SalesArea:Safe: MagnumSafe:Date/Time of Transfer: 04/01/2021 10:18:28Date/Time of Acknowledgement:
04/01/2021 21:21:41​
Transfer Make-up:
R10 Fit
20.00​
R50 Fit
250.00​
R100 Fit
100.00​
R200 Fit
400.00​
Total:
770.00​
Transfer Status - Acknowledged
SourceDestinationInitiated by:Username: MikeUsername: PatrickArea: AdminArea:Safe:Safe: ChubbDate/Time of Transfer: 04/01/2021 10:19:48Date/Time of Acknowledgement:
04/01/2021 21:21:41​
Transfer Make-up:
R200 Fit
600.00​
Total:
600.00​
Transfer Status - Acknowledged
SourceDestinationInitiated by:Username: BrentonUsername: JillArea: SalesArea:Safe:Safe:Date/Time of Transfer: 04/01/2021 10:23:29Date/Time of Acknowledgement:
04/01/2021 21:21:41​
Transfer Make-up:
R50 Fit
250.00​
R100 Fit
300.00​
R200 Fit
200.00​
Total:
750.00​
Transfer Status - Rejected
SourceDestinationInitiated by:Username: J
ane
Username: AstridArea:Area:Safe:Safe:Date/Time of Transfer: 04/01/2021 14:50:30Date/Time of Acknowledgement:
04/01/2021 21:21:41​
Transfer Make-up:
R10 Fit
20.00​
R20 Fit
60.00​
R50 Fit
150.00​
R100 Fit
100.00​
R200 Fit
600.00​
R10 Unfit
40.00​
R20 Unfit
60.00​
R50 Unfit
200.00​
R100 Unfit
100.00​
R200 Unfit
200.00​
Total:
1,530.00​
Transfer Status - Acknowledged

Results Required:
Transfer StatusSourceDestinationTotal:
Username:Area:Safe:Username:Area:Safe:
Transfer Status - AcknowledgedAcknowledgedBrentonSalesMagnumJane770.00
Transfer Status - AcknowledgedAcknowledgedMikeAdminPatrikChubb600.00
Transfer Status - RejectedRejectedBrentonSalesJill750.00
Transfer Status - AcknowledgedAcknowledgedJaneAstrid1,530.00

The data lines will change daily so the "source" will not always be on a specific lines as per the Data.
 
Upvote 0
Thank you.

Assuming ..
  • Original data is on a sheet called 'Data' (change it in the code if not)
  • Results to go on a sheet called 'Results' (change it in the code if not)
  • 'Results' sheet already exists in the workbook but with no data in it (post back with details if this assumption is incorrect)
... then try this with a copy of your workbook.

VBA Code:
Sub Transactions()
  Dim a As Variant, b As Variant
  Dim i As Long, k As Long
  
  a = Sheets("Data").UsedRange.Value
  ReDim b(1 To Rows.Count, 1 To 9)
  For i = 1 To UBound(a)
    Select Case a(i, 1)
      Case "Source"
        k = k + 1
        b(k, 3) = Trim(Mid(a(i, 5), 10))
        b(k, 6) = Trim(Mid(a(i, 6), 10))
        b(k, 4) = Trim(Mid(a(i, 7), 6))
        b(k, 7) = Trim(Mid(a(i, 8), 6))
        b(k, 5) = Trim(Mid(a(i, 9), 6))
        b(k, 8) = Trim(Mid(a(i, 10), 6))
      Case "Total:"
        b(k, 1) = a(i, 3)
        b(k, 2) = Trim(Mid(b(k, 1), 18))
        b(k, 9) = a(i, 2)
    End Select
  Next i
  With Sheets("Results")
    .Range("A1:I1").Value = Array("", "Transfer Status", "Source", "", "", "Destination", "", "", "Total:")
    .Range("A2:I2").Value = Array("", "", "Username:", "Area:", "Safe:", "Username:", "Area:", "Safe:", "")
    .Range("A3").Resize(k, UBound(b, 2)).Value = b
    .UsedRange.Columns.AutoFit
  End With
End Sub

Here is my' Data' sheet

Brentsa.xlsm
ABCDEFGHIJKLMN
1Selected User:ALL
2SourceDestinationInitiated by:Username: BrentonUsername: JaneArea: SalesArea:Safe: MagnumSafe:Date/Time of Transfer: 04/01/2021 10:18:28Date/Time of Acknowledgement:1/04/2021 21:21Transfer Make-up:
3R10 Fit20
4R50 Fit250
5R100 Fit100
6R200 Fit400
7Total:770Transfer Status - Acknowledged
8SourceDestinationInitiated by:Username: MikeUsername: PatrickArea: AdminArea:Safe:Safe: ChubbDate/Time of Transfer: 04/01/2021 10:19:48Date/Time of Acknowledgement:1/04/2021 21:21Transfer Make-up:
9R200 Fit600
10Total:600Transfer Status - Acknowledged
11SourceDestinationInitiated by:Username: BrentonUsername: JillArea: SalesArea:Safe:Safe:Date/Time of Transfer: 04/01/2021 10:23:29Date/Time of Acknowledgement:1/04/2021 21:21Transfer Make-up:
12R50 Fit250
13R100 Fit300
14R200 Fit200
15Total:750Transfer Status - Rejected
16SourceDestinationInitiated by:Username: JaneUsername: AstridArea:Area:Safe:Safe:Date/Time of Transfer: 04/01/2021 14:50:30Date/Time of Acknowledgement:1/04/2021 21:21Transfer Make-up:
17R10 Fit20
18R20 Fit60
19R50 Fit150
20R100 Fit100
21R200 Fit600
22R10 Unfit40
23R20 Unfit60
24R50 Unfit200
25R100 Unfit100
26R200 Unfit200
27Total:1,530.00Transfer Status - Acknowledged
Data



.. and 'Results' sheet after the code has run

Brentsa.xlsm
ABCDEFGHI
1Transfer StatusSourceDestinationTotal:
2Username:Area:Safe:Username:Area:Safe:
3Transfer Status - AcknowledgedAcknowledgedBrentonSalesMagnumJane770
4Transfer Status - AcknowledgedAcknowledgedMikeAdminPatrickChubb600
5Transfer Status - RejectedRejectedBrentonSalesJill750
6Transfer Status - AcknowledgedAcknowledgedJaneAstrid1530
Results
 
Upvote 0
Solution

Forum statistics

Threads
1,215,221
Messages
6,123,701
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top