financial_analyst22
New Member
- Joined
- May 21, 2019
- Messages
- 1
Hi Everyone,
I am no VBA expert and appreciate any help you can provide. I would like to learn how to search for a before and after instance to copy and paste information in between those two instances. And then repeat the process. This helps to create a format usable for a pivot table.
For example if my report looks like: 1) the account information (and beginning balance) in its own row, 2) all the transactions for that account in the rows below, followed by 3) an ending balance, and then it repeats with a new account followed by those transactions and an ending balance, and so on
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Row #[/TD]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD]Account Information 1[/TD]
[TD][/TD]
[TD]"Beginning Balance"[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD]Ending Balance thru...[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD]Account Information 2[/TD]
[TD][/TD]
[TD]"Beginning Balance"[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD]Ending Balance thru...[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD]Account Information 3[/TD]
[TD][/TD]
[TD]"Beginning Balance"[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD][/TD]
[TD]Account Information 4[/TD]
[TD][/TD]
[TD]"Beginning Balance"[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD][/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD][/TD]
[TD]Ending Balance thru...[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I would like to:
1) Search for "Beginning Balance" in column D. There is a beginning balance instance in column D for every new account.
2) Then I would like to copy a TRIMMED version (there are extra spaces that I don't want) of the column B account information into column A next to every Transaction until I reach the ending balance row.
3) I would like this to repeat for every account section.
4) Final step: delete the account information/beginning balance rows & the ending balance rows
Note: There are some instances where there is a row for an account and beginning balance but no transactions and no ending balance row so those will need to be skipped over. (Example in row 8 for Account Information 3)
Goal Table:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Row #[/TD]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Account Information 1[/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Account Information 1[/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Account Information 2[/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Account Information 4[/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
</tbody>[/TABLE]
Thank you in advance for your help!
I am no VBA expert and appreciate any help you can provide. I would like to learn how to search for a before and after instance to copy and paste information in between those two instances. And then repeat the process. This helps to create a format usable for a pivot table.
For example if my report looks like: 1) the account information (and beginning balance) in its own row, 2) all the transactions for that account in the rows below, followed by 3) an ending balance, and then it repeats with a new account followed by those transactions and an ending balance, and so on
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Row #[/TD]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD]Account Information 1[/TD]
[TD][/TD]
[TD]"Beginning Balance"[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD]Ending Balance thru...[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD]Account Information 2[/TD]
[TD][/TD]
[TD]"Beginning Balance"[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD]Ending Balance thru...[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD]Account Information 3[/TD]
[TD][/TD]
[TD]"Beginning Balance"[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD][/TD]
[TD]Account Information 4[/TD]
[TD][/TD]
[TD]"Beginning Balance"[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD][/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD][/TD]
[TD]Ending Balance thru...[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I would like to:
1) Search for "Beginning Balance" in column D. There is a beginning balance instance in column D for every new account.
2) Then I would like to copy a TRIMMED version (there are extra spaces that I don't want) of the column B account information into column A next to every Transaction until I reach the ending balance row.
3) I would like this to repeat for every account section.
4) Final step: delete the account information/beginning balance rows & the ending balance rows
Note: There are some instances where there is a row for an account and beginning balance but no transactions and no ending balance row so those will need to be skipped over. (Example in row 8 for Account Information 3)
Goal Table:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Row #[/TD]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Account Information 1[/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Account Information 1[/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Account Information 2[/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Account Information 4[/TD]
[TD]Date of Transaction[/TD]
[TD]Transaction Info.[/TD]
[TD]Transaction Info.[/TD]
[/TR]
</tbody>[/TABLE]
Thank you in advance for your help!