Consulting

Results 1 to 7 of 7

Thread: Solved: is there a paste special for this data?

  1. #1

    Solved: is there a paste special for this data?

    I don;t know if this is asking to much from excel.

    But, is there a way to do a paste special for my excel concern?

    Please see attached sample.

    Is it possible that Sheet 1(Orig Data)
    will look like Sheet 2(Is this Possible)

    Paste Special - Tranpose doesn't work, so maybe a VBA code will be able to solve this problem.

    Thanks! I appreciate all your help.

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings genracela,

    A couple of questions:
    1. Does the formatting (font/interior colors and such) matter, or do we just need the values?
    2. Can we count on a 28 day cycle, or do we need to find the last column?
    Thanks,

    Mark

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub ProcessData()
    Const TEST_COLUMN As String = "A" '<=== change to suit
    Dim i As Long, j As Long
    Dim LastRow As Long
    Dim LastCol As Long

    With ActiveSheet

    LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
    LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    .Columns(3).Insert
    For i = LastRow To 2 Step -1

    .Rows(i + 1).Resize(LastCol - 2).Insert
    .Cells(1, "D").Resize(, LastCol - 2).Copy
    .Cells(i + 1, "C").Resize(LastCol - 2).PasteSpecial _
    Paste:=xlPasteAll, _
    Transpose:=True
    .Cells(i, "D").Resize(, LastCol - 2).Copy
    .Cells(i + 1, "D").Resize(LastCol - 2).PasteSpecial _
    Paste:=xlPasteAll, _
    Transpose:=True
    .Cells(i, "A").Resize(, 2).AutoFill .Cells(i, "A").Resize(LastCol - 1, 2)
    .Rows(i).Delete
    Next i

    .Columns(3).AutoFit
    .Range("C11").Value = Array("Date", "Qty")
    .Range("D1").Resize(LastCol - 3).ClearContents
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Maybe the slightest tweak to the last bit.

            '// Change...
            '.Range("D1").Resize(LastCol - 3).ClearContents
            '// ..to..
            .Range("E1").Resize(, LastCol - 3).Clear
            '// To rid the selection   //
            .Range("A1").Select
        End With

  5. #5
    I tried the code, and it worked, but there's a slight problem.

    D2: D27 is blank. It supposed to have qty.

    Thanks for all the help!
    Last edited by genracela; 05-05-2010 at 05:55 PM.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Missing comma

    [vba]

    Public Sub ProcessData()
    Const TEST_COLUMN As String = "A" '<=== change to suit
    Dim i As Long, j As Long
    Dim LastRow As Long
    Dim LastCol As Long

    Application.ScreenUpdating = False

    With ActiveSheet

    LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
    LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    .Columns(3).Insert
    For i = LastRow To 2 Step -1

    Debug.Assert i <> 2
    .Rows(i + 1).Resize(LastCol - 2).Insert
    .Cells(1, "D").Resize(, LastCol - 2).Copy
    .Cells(i + 1, "C").Resize(LastCol - 2).PasteSpecial _
    Paste:=xlPasteAll, _
    Transpose:=True
    .Cells(i, "D").Resize(, LastCol - 2).Copy
    .Cells(i + 1, "D").Resize(LastCol - 2).PasteSpecial _
    Paste:=xlPasteAll, _
    Transpose:=True
    .Cells(i, "A").Resize(, 2).AutoFill .Cells(i, "A").Resize(LastCol - 1, 2)
    .Rows(i).Delete
    Next i

    .Columns(3).AutoFit
    .Range("C11").Value = Array("Date", "Qty")
    .Range("D1").Resize(, LastCol - 3).ClearContents
    End With

    Application.ScreenUpdating = True

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Thanks again XLD!

Posting Permissions

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