Results 1 to 5 of 5

Cleanup Cell formatting on each tab after code is run!

Threaded View

bigroo1958 Cleanup Cell formatting on... 02-03-2014, 08:28 AM
natefarm Re: Cleanup Cell formatting... 02-03-2014, 03:10 PM
bigroo1958 Re: Cleanup Cell formatting... 02-03-2014, 07:20 PM
natefarm Re: Cleanup Cell formatting... 02-04-2014, 11:46 AM
bigroo1958 Re: Cleanup Cell formatting... 02-04-2014, 09:11 PM
  1. #1
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    Cleanup Cell formatting on each tab after code is run!

    I have code within my spreadsheet that will transfer my data from the "Master" to the different labeled tabs which Alansidman helped me with.

    Here is a link to my first question


    I now have two other tasks I wish to perform which I did not take into account on my first initial question.

    One: I wish to clear the data area on each of the green tabs from range A14 to F113 before running the code, this is so when I replace the previous months data I with new data I don't have any data remaining and skewing my figures.

    Two: When I run the code to populate the green tabs, I wish to place the cell borders back in from range A14 to F113 on these tabs only.

    I hope I have made myself clear as to what I am looking for!

    Thanks

    Sub Master()
        Dim w1 As Worksheet
        Dim w2 As Worksheet
        Dim w3 As Worksheet
        Dim w4 As Worksheet
        Dim w5 As Worksheet
        Dim w6 As Worksheet
        Dim w7 As Worksheet
        Dim w8 As Worksheet
        Set w1 = Sheets("Master")
        Set w2 = Sheets("NVC")
        Set w3 = Sheets("NLV")
        Set w4 = Sheets("NWV")
        Set w5 = Sheets("PAC")
        Set w6 = Sheets("SAC")
        Set w7 = Sheets("SPC")
        Set w8 = Sheets("DISTRICT")
        Dim i As Long
        Dim lr As Long
        lr = w1.Range("K" & Rows.Count).End(xlUp).Row
        Dim lr2 As Long
        Dim lr3 As Long
        Dim lr4 As Long
        Dim lr5 As Long
        Dim lr6 As Long
        Dim lr7 As Long
        Dim lr8 As Long
            
        Application.ScreenUpdating = False
        
        For i = 4 To lr
        lr2 = w2.Range("A" & Rows.Count).End(xlUp).Row
        lr3 = w3.Range("A" & Rows.Count).End(xlUp).Row
        lr4 = w4.Range("A" & Rows.Count).End(xlUp).Row
        lr5 = w5.Range("A" & Rows.Count).End(xlUp).Row
        lr6 = w6.Range("A" & Rows.Count).End(xlUp).Row
        lr7 = w7.Range("A" & Rows.Count).End(xlUp).Row
        lr8 = w8.Range("A" & Rows.Count).End(xlUp).Row
        
        If Range("K" & i) = "NVC" Then
        Union(Cells(i, 1), Cells(i, 2), Cells(i, 8), Cells(i, 12), Cells(i, 13)).Copy w2.Range("A" & lr2 + 1)
            ElseIf Range("K" & i) = "NLV" Then
            Union(Cells(i, 1), Cells(i, 2), Cells(i, 8), Cells(i, 12), Cells(i, 13)).Copy w3.Range("A" & lr3 + 1)
                ElseIf Range("K" & i) = "NWV" Then
                Union(Cells(i, 1), Cells(i, 2), Cells(i, 8), Cells(i, 12), Cells(i, 13)).Copy w4.Range("A" & lr4 + 1)
                    ElseIf Range("K" & i) = "PAC" Then
                    Union(Cells(i, 1), Cells(i, 2), Cells(i, 8), Cells(i, 12), Cells(i, 13)).Copy w5.Range("A" & lr5 + 1)
                        ElseIf Range("K" & i) = "SAC" Then
                        Union(Cells(i, 1), Cells(i, 2), Cells(i, 8), Cells(i, 12), Cells(i, 13)).Copy w6.Range("A" & lr6 + 1)
                            ElseIf Range("K" & i) = "SPC" Then
                            Union(Cells(i, 1), Cells(i, 2), Cells(i, 8), Cells(i, 12), Cells(i, 13)).Copy w7.Range("A" & lr7 + 1)
                                ElseIf Range("K" & i) = "District" Then
                                Union(Cells(i, 1), Cells(i, 2), Cells(i, 8), Cells(i, 12), Cells(i, 13)).Copy w8.Range("A" & lr8 + 1)
        End If
        Next i
        
        Application.CutCopyMode = False
        Application.ScreenUpdating = False
        MsgBox ("Task Completed")
        
    End Sub
    Attached Files Attached Files
    ==========
    Bigroo1958
    Austin, Texas
    ==========

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Code Cleanup
    By KevBotes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-04-2012, 02:09 PM
  2. [SOLVED] Code Cleanup Help
    By maddog9486 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2011, 02:19 PM
  3. Looking to Cleanup my Code
    By thundermocos in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-30-2007, 04:25 PM
  4. [SOLVED] Code Cleanup
    By P J H in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-03-2006, 11:30 AM
  5. Code cleanup
    By peter.thompson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2006, 02:16 AM

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