Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Aug 2003
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    copy selection and paste to one page (excel 2003)

    How to clone the small selection to fill up one whole page in macro. My selection usually contains few rows and few columns with different height and width. It is best the last pasted row and column selection will go beyond the page border a little bit more if it is not exact at the page border, so I will manually adjust the selection to decide I will keep the last pasted selection.
    thank you!

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: copy selection and paste to one page (excel 2003)

    I'm sorry, but I don't understand what you have and what you want.

    Could you elaborate on what exactly you are trying to do?

    Steve

  3. #3
    Star Lounger
    Join Date
    Aug 2003
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy selection and paste to one page (excel 2003)

    here is the attachment.

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy selection and paste to one page (excel 2003)

    Your "selection" starts with a divisor of 8 and a dividend of 24 in A13. What caused that to change to a devisor of 7 and a dividend of 7 in the result sheet?

    Given the divisor of 8 and the dividend of 24 in A13, what calculation is being done or what rule is being followed to get the numbers in your result sheet?

    The methodology of getting from the selection to the result is not obvious to me.
    Legare Coleman

  5. #5
    Star Lounger
    Join Date
    Aug 2003
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy selection and paste to one page (excel 2003)

    the selection is the set of formula with random number. I do not care about the content of the cells. Basically, I create a math practice equation and would like to copy that and paste it to whole page. then the whole page will fill up with different math exercise equation. if press F9, all equation will change.

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: copy selection and paste to one page (excel 2003)

    I am not sure exactly what you need, could you elaborate?

    To how many columns do you want to paste?
    To how many rows?

    Will the selection to copy always be the same size?
    Do you plan on adjusting the column widths also? Manually or via the code?

    Steve

  7. #7
    Star Lounger
    Join Date
    Aug 2003
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy selection and paste to one page (excel 2003)

    the selection is not always the same size. That is why the number of rows and columns can not be determined. When pasted, I like it come up with same column widths and row heights of the selection. do not want auto adjust because the random number sometimes 1 , 2 or 3 digits and in the selection I preset the width for the max digits.
    sorry for the confuse.

  8. #8
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy selection and paste to one page (excel 2003)

    Does this do what you want:

    <pre>Public Sub BuildSheet()
    Dim I As Long, lSCols As Long, lSRows As Long
    lSCols = Selection.Columns.Count
    lSRows = Selection.Rows.Count
    I = 1
    Selection.EntireColumn.Copy
    Do While I * lSCols < 23
    ActiveSheet.Paste Destination:=Selection.Cells(1).Offset(0, I * lSCols)
    I = I + 1
    Loop
    I = 1
    Selection.EntireRow.Copy
    Do While I * lSRows < 28
    ActiveSheet.Paste Destination:=Selection.Cells(1).Offset(I * lSRows, 0)
    I = I + 1
    Loop
    Application.CutCopyMode = False
    End Sub
    </pre>

    Legare Coleman

  9. #9
    Star Lounger
    Join Date
    Aug 2003
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy selection and paste to one page (excel 2003)

    Thank you Legare. It works great for this selection. But if different selection is selected, it may go beyond the page border a lot or have lot of space within the border.

  10. #10
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy selection and paste to one page (excel 2003)

    Page borders are not readily available in VBA code and are very complex to try to calculate. The best suggestion I have is to run the macro and then manually delete what falls outside the page borders.
    Legare Coleman

  11. #11
    Star Lounger
    Join Date
    Aug 2003
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy selection and paste to one page (excel 2003)

    thank you for your suggetion.

Posting Permissions

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