Automatically Parsing a Spreadsheet

scm24

New Member
Joined
Jun 4, 2009
Messages
5
The code below attempts to parse the worksheet COPY_APR_All_States based upon the state (column "F") by making a new worksheet (named by State, the "holdState" variable) for every state found in column "F" of COPY_APR_All_States, and then adding the respective rows to the new worksheet.

I have checked that COPY_APR_All_States is populated and sorted correctly, and I have added Error Checking to the Sub. However, the code below only creates a Worksheet for DC (there's another 12 states in COPY_APR) and does not copy any of the rows. I don't receive any errors when this task is executed or completed.

Any ideas on what is wrong here?

Thanks in advance!

Code:
'Create A Worksheet for Each State then Copy & Paste the Information
        Sheets("Copy_APR_ALL_States").Select
        Range("F3").Select
        holdState = ActiveCell.Value
 
        For i = 1 To 750
 
            If holdState <> "" Then
 
                Set state = Sheets.Add
                Sheets.Add.Name = holdState
 
                Do While UCase(ActiveCell.Value) = UCase(holdState)
 
                    Range("F" & i + 2).Select
                    ActiveCell.EntireRow.Select
                    Selection.Copy
                    Sheets(holdState).Select
                    Range("A" & i).Select
                    Selection.Paste
                    Sheets("Copy_APR_ALL_States").Select
                    Range("F" & i + 2).Select
                    ActiveCell.Offset(1, 0).Select
 
                Loop
 
            Else
 
                ActiveCell.Offset(1, 0).Select
 
            End If
 
            holdState = ActiveCell.Value
 
        Next i
<!-- END TEMPLATE: bbcode_code -->
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,215,214
Messages
6,123,665
Members
449,114
Latest member
aides

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