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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
44,653
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
44,653
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,186
Messages
5,509,684
Members
408,749
Latest member
Bhuvaneshvar kashyap

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top