+ Reply to Thread
Results 1 to 2 of 2

Automatically Parsing a Spreadsheet

Hybrid View

  1. #1
    Registered User
    Join Date
    06-03-2009
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Automatically Parsing a Spreadsheet

    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!


    '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

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatically Parsing a Spreadsheet

    A sample workbook to try this on, too, would be most helpful. Click on GO ADVANCED in a new message and use the paperclip icon to upload on for us. The problem could be in the dataset.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1