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.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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