+ Reply to Thread
Results 1 to 3 of 3

paste special with widths & formats

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    paste special with widths & formats

    Hi could someone please tell me how to paste special with correct widths as well as formats at the same time if possible.
    I can copy cells from one sheet to another and get the format ok but how do I get the correct width.
    Thanks

    Dim rSource As Excel.Range
        Dim rDestination As Excel.Range
        
       
        
        Worksheets("Main").Activate
        Set rSource = ActiveSheet.Range("b:b")
    
        Selection.AutoFilter Field:=3, Criteria1:="Bakery"
        rSource.Copy
        Worksheets("Main2").Activate
         Set rDestination = ActiveSheet.Range("a:a")
        rDestination.Select
    
        Selection.PasteSpecial Paste:=xlPasteFormats, _
        operation:=xlNone, _
        skipblanks:=False, _
        Transpose:=False

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: paste special with widths & formats

    Hi I do not understand your code (part of code?) but if you want keep the width of column and transfer this to another copied column look at such code and try to adjust it.
    Sub aa()
    Dim x As Long
    
    x = Worksheets("Main").Columns("b").ColumnWidth
    
    Worksheets("Main").Columns("b").Copy Worksheets("Main2").Columns("a")
    Worksheets("Main2").Columns("a").ColumnWidth = x
    
    End Sub
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Re: paste special with widths & formats

    Thanks that helped a lot.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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