select contiguous values in col A

srschicago

Board Regular
Joined
Apr 14, 2017
Messages
59
Hey guys,
I have a worksheet with a series of contiguous values (some are numbers and some are text) in column A with related data in columns B:E. I need to split this data into separate files with the name of the Col A contiguous value in the file name. I have been looking at various countif and current range functions but am struggling to get the Col A range selected. I am also struggling with getting the cell value set as the variable to use in the filename. Can you help me out?
I intend to delete each contiguous range from the worksheet after I copy it to the separate file, leaving each next contiguous value range starting in A2. (I need the header row included in each file data) I would really appreciate some help.
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,669
Office Version
365
Platform
Windows
How about something like
Code:
Sub srschicago()
   Dim Cl As Range
   Dim ws As Worksheet
   Dim Ky As Variant
   
   Application.ScreenUpdating = False
   Set ws = Sheets("sheet1")
   With CreateObject("scripting.dictionary")
      For Each Cl In ws.Range("A2", ws.Range("A" & Rows.count).End(xlUp))
         If Not .Exists(Cl.Value) Then .Add Cl.Value, Nothing
      Next Cl
      For Each Ky In .Keys
         ws.Copy
         Range("A1:E1").AutoFilter 1, "<>" & Ky
         ActiveSheet.AutoFilter.Range.Offset(1).EntireRow.Delete
         Range("A1:E1").AutoFilter
         ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & Ky, 51
         ActiveWorkbook.Close False
      Next Ky
   End With
End Sub
 

srschicago

Board Regular
Joined
Apr 14, 2017
Messages
59
That worked fantastically Fluff! Over 3K of files created in 10 minutes. You are my hero!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,669
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,102,362
Messages
5,486,395
Members
407,544
Latest member
mguevara

This Week's Hot Topics

Top