none
Pasting and maintaining cell sizes in excel RRS feed

  • Question

  • Is it possible to paste the contents I have copies into another sheet and maintain the cell sizes?

    I have this:

    Sheets("Sheet3").Select
    ActiveSheet.Paste

    Are there options in the Paste function to maintain cell sizes?


    Wednesday, January 15, 2014 8:12 PM

All replies

  • Re:  maintain cell size when pasting

       

    The column widths can be done when you paste but the row height will have to be separately...
    '---
    Sub LookTheSame()
      Dim rng As Excel.Range
      Dim Num As Long

      Set rng = Worksheets(1).Range("B3:D5")
      rng.Copy
      Worksheets("Sheet3").Range("B3:D5").PasteSpecial Paste:=xlPasteAll
      Worksheets("Sheet3").Range("B3:D5").PasteSpecial Paste:=xlPasteColumnWidths
      Application.CutCopyMode = False

      For Num = 1 To rng.Rows.Count
        Worksheets("Sheet3").Range("B3:D5").Rows(Num).RowHeight = rng.Rows(Num).RowHeight
      Next
    End Sub

    '---
    Jim Cone
    Portland, Oregon USA
    https://goo.gl/IUQUN2 (Dropbox)
    (free & commercial excel add-ins & workbooks)

    • Edited by James Cone Tuesday, October 25, 2016 1:29 AM
    Thursday, January 16, 2014 12:16 AM