Consulting

Results 1 to 4 of 4

Thread: Different Language Has Different Character Widths

  1. #1

    Different Language Has Different Character Widths

    Hi,

    I want to copy the data from selected row (suppose R1 to R10) from sheet "Data1" and then paste into another sheet "Data2", the headers are not being populated properly.

    As the fonts in the header are in some other language, the original requester want the header to be exactly same (without any space) to the copied one which I am not able to do.

    e.g. I copied the data from R1-R10 and paste in other sheet "Data2". -->i) Header in column c are not populated exactly .
    ii) Header in column I of sheet Data1 is more widened compared to col I of data2.

    Is it possible to develop macro which will keep the exact copy to copied sheet. (See attached sheet)

    Advance thanks
    Attached Files Attached Files

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Abraham,

    I changed the title to attract more responses.

    Have you tried the macro on the requester's computer. It may just be that it is responding to the default language on your computer and will work fine on his/hers.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    I'm not sure if I understand exactly what you are looking for here, but if what you want is to keep the column widths in the second sheet, couldn't you use something like "Paste special" -> "Column widths"?

    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Maybe like this?


    Option Explicit
    Sub Macro1()
        Dim rSource As Range, rDest As Range
        Dim iColumn As Long
        Set rSource = Worksheets("Data1").Cells(1, 1).CurrentRegion
        Set rSource = rSource.Cells(1, 1).Resize(10, rSource.Parent.Columns.Count)
        
        rSource.Copy
        
        Worksheets("Data2").Cells(1, 1).Select
        Selection.PasteSpecial Paste:=xlPasteValues
        Selection.PasteSpecial Paste:=xlPasteFormats
        Set rDest = Worksheets("Data2").Cells(1, 1).CurrentRegion
        
        
        For iColumn = 1 To rSource.Columns.Count
            rDest.Columns(iColumn).ColumnWidth = rSource.Columns(iColumn).ColumnWidth
        Next iColumn
    End Sub
    Paul

Posting Permissions

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