Copy data between 2 empty lines save as new file and then next

Milena

New Member
Joined
Jul 29, 2015
Messages
3
Hi,

I was wondering if anybody will be able to help me.
I am fairly new to VBA.

I have created a macro that will pull the data from file based on multiple criteria, group them together, assign invoice number and separate the invoices with blank rows. It will look something like this (with a lot more columns):

[TABLE="class: grid, width: 100"]
<tbody>[TR]
[TD]invoice number[/TD]
[TD]description[/TD]
[TD]value[/TD]
[/TR]
[TR]
[TD]NL1[/TD]
[TD]aaaaa[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]bbbbb[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NL2[/TD]
[TD]aaaa[/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]ccccc[/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]ddddd[/TD]
[TD]40[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NL3[/TD]
[TD]bbb[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]aaaaa[/TD]
[TD]30[/TD]
[/TR]
</tbody>[/TABLE]

How do I then copy the information between the blank lines into separate files (I need to create proforma invoices).
So all transactions for NL1 as 1 file, NL2 as another file ect. Is that possible?


The number of invoices will vary each month and there can be various number of items per 1 invoice. Invoices are numbered sequentially.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
How about
Code:
Sub Milena()
   Dim Rng As Range
   Application.ScreenUpdating = False
   For Each Rng In Range("B2", Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
      Workbooks.Add
      Rng.EntireRow.Copy Range("A1")
      With ActiveWorkbook
         .SaveAs ThisWorkbook.path & "\" & Rng.Offset(, -1).Resize(1, 1).Value, 52
         .Close
      End With
   Next Rng
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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