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):

invoice numberdescriptionvalue
NL1aaaaa10
bbbbb20
NL2aaaa12
ccccc30
ddddd40
NL3bbb10
aaaaa30

<tbody>
</tbody>

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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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