Results 1 to 8 of 8

Keep Formatting/Column Widths in this VB

Threaded View

votekinky06 Keep Formatting/Column Widths... 03-17-2014, 12:13 PM
TMS Re: Need Help! Should be easy... 03-17-2014, 12:17 PM
votekinky06 Re: Need Help! Should be easy... 03-17-2014, 12:20 PM
TMS Re: Keep Formatting/Column... 03-17-2014, 12:18 PM
TMS Re: Keep Formatting/Column... 03-17-2014, 12:36 PM
votekinky06 Re: Keep Formatting/Column... 03-17-2014, 12:46 PM
TMS Re: Keep Formatting/Column... 03-17-2014, 12:51 PM
votekinky06 Re: Need Help! Should be easy... 03-17-2014, 12:18 PM
  1. #1
    Registered User
    Join Date
    03-10-2014
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    42

    Keep Formatting/Column Widths in this VB

    This is doing ALMOST everything I need it to do. The only thing I need is for it to keep the formatting and column widths from the source sheet. Any help would be GREATLY appreciated. Thanks all!

    Sub DistributeAccounts()
        Const NameCol = "A"
        Const HeaderRow = 1
        Const FirstRow = 11
        Dim SrcSheet As Worksheet
        Dim TrgSheet As Worksheet
        Dim SrcRow As Long
        Dim LastRow As Long
        Dim TrgRow As Long
        Dim Student As String
        Application.ScreenUpdating = False
        Set SrcSheet = ActiveSheet
        LastRow = SrcSheet.Cells(SrcSheet.Rows.Count, NameCol).End(xlUp).Row
        For SrcRow = FirstRow To LastRow
            Student = SrcSheet.Cells(SrcRow, NameCol).Value
            Set TrgSheet = Nothing
            On Error Resume Next
            Set TrgSheet = Worksheets(Student)
            On Error GoTo 0
            If TrgSheet Is Nothing Then
                Set TrgSheet = Worksheets.Add(After:=Worksheets(Worksheets.Count))
                TrgSheet.Name = Student
                SrcSheet.Range("A1:AG10").Copy Destination:=TrgSheet.Rows(HeaderRow)
            End If
            TrgRow = TrgSheet.Cells(TrgSheet.Rows.Count, NameCol).End(xlUp).Row + 1
            SrcSheet.Rows(SrcRow).Copy Destination:=TrgSheet.Rows(TrgRow)
        Next SrcRow
        Application.ScreenUpdating = True
    End Sub
    Last edited by votekinky06; 03-17-2014 at 12:47 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Hello All Excel experts and (like me) non experts !
    By markymark& in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 03-03-2013, 09:09 AM
  2. Matrix Fill - Easy but a challenge for experts!!!
    By sadiqueakhter in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-06-2013, 08:02 AM
  3. [SOLVED] Easy 'Conditional Formatting' Question For You Experts
    By yakabod in forum Excel General
    Replies: 5
    Last Post: 12-04-2012, 12:21 PM
  4. [SOLVED] easy qustion for excel experts
    By Digital2k in forum Excel General
    Replies: 9
    Last Post: 07-15-2006, 10:45 PM
  5. [SOLVED] combining rows and deleting easy for u experts
    By bamamike in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2005, 10:05 PM

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