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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Fluff

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

Watch MrExcel Video

Forum statistics

Threads
1,102,691
Messages
5,488,293
Members
407,633
Latest member
varunwalla

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top