• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Loop to copy unique values in column to new workbook - Bug

bvanscoy678

Member
Hi,

I received this code from a previous question and it worked perfect for another project.

I started a new project today and it only pulls the first value, exits the loop and then I get an error when it tries to save over the same file. It only copies one row, then exits the loop. I have checked the formatting of the column (2) I am using for the unique values and it is the same. In stepping through the code and looking at the variables, I don't see why it won't go past the first value. I can see it finds the correct last row.

I attached the sample workbook to help with my question. The 2nd Row, 2nd Column has a value of "E30A" . The code should look down to the last row and then copy all "E30A" rows to a new workbook (I think it actually deletes the other rows). This way I end up with a workbook for each unique value in the 2nd column.

I just used this code for another project and it worked perfect.

Thanks for any help, Brent
 

Attachments

  • Chandoo.xlsm
    218.3 KB · Views: 15
Hi Brent ,

The following comment in the macro is worth considering :

' Note: Values in the column should be unique or sorted.

I ran the macro , and when it asks whether it can overwrite any existing file , if you select YES , there is no problem.

Narayan
 
Hi Brent ,

The following comment in the macro is worth considering :

' Note: Values in the column should be unique or sorted.

I ran the macro , and when it asks whether it can overwrite any existing file , if you select YES , there is no problem.

Narayan

I think Narayan hit it on the head. Ron's code that I linked to does not require data to be sorted/unique, if that is something you want to avoid, fyi.
 
Back
Top