+ Reply to Thread
Results 1 to 2 of 2

Pasting problems

  1. #1
    cvach
    Guest

    Pasting problems

    I have this code thus far. I want all of this information to be on the
    same line but as of right now it buts it on two seperate lines. How
    can I combine the codes and have them com in on the same line.

    Sub copy_1_Values_PasteSpecial()
    Dim sourceRange As Range
    Dim destrange As Range
    Dim Lr As Long
    Application.ScreenUpdating = False
    Lr = LastRow(Sheets("Invoices")) + 1
    Set sourceRange = Sheets("PO Form").Range("A44:G44")
    Set destrange = Sheets("Invoices").Range("A" & Lr)
    sourceRange.Copy
    destrange.PasteSpecial xlPasteValues, , False, False
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub

    Sub copy_3_Values_PasteSpecial()
    Dim sourceRange As Range
    Dim destrange As Range
    Dim Lr As Long
    Application.ScreenUpdating = False
    Lr = LastRow(Sheets("Invoices")) + 1
    Set sourceRange = Sheets("PO Form").Range("H44:H44")
    Set destrange = Sheets("Invoices").Range("H" & Lr)
    sourceRange.Copy
    destrange.PasteSpecial xlPasteFormulas, , False, False
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub

    Function LastRow(sh As Worksheet)
    On Error Resume Next
    LastRow = sh.Cells.Find(What:="*", _
    After:=sh.Range("A1"), _
    Lookat:=xlPart, _
    LookIn:=xlFormulas, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious, _
    MatchCase:=False).Row
    On Error GoTo 0
    End Function


  2. #2
    Tom Ogilvy
    Guest

    Re: Pasting problems

    I assume there is some good reason you are using separate procedures to do
    the copy. If you always do copy_1_Values_PasteSpecial first, then

    Sub copy_1_Values_PasteSpecial()
    Dim sourceRange As Range
    Dim destrange As Range
    Dim Lr As Long
    Application.ScreenUpdating = False
    Lr = LastRow(Sheets("Invoices")) + 1
    Set sourceRange = Sheets("PO Form").Range("A44:G44")
    Set destrange = Sheets("Invoices").Range("A" & Lr)
    sourceRange.Copy
    destrange.PasteSpecial xlPasteValues, , False, False
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub

    Sub copy_3_Values_PasteSpecial()
    Dim sourceRange As Range
    Dim destrange As Range
    Dim Lr As Long
    Application.ScreenUpdating = False
    ' don't add a 1 here
    Lr = LastRow(Sheets("Invoices"))
    Set sourceRange = Sheets("PO Form").Range("H44:H44")
    Set destrange = Sheets("Invoices").Range("H" & Lr)
    sourceRange.Copy
    destrange.PasteSpecial xlPasteFormulas, , False, False
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub

    Function LastRow(sh As Worksheet)
    On Error Resume Next
    LastRow = sh.Cells.Find(What:="*", _
    After:=sh.Range("A1"), _
    Lookat:=xlPart, _
    LookIn:=xlFormulas, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious, _
    MatchCase:=False).Row
    On Error GoTo 0
    End Function


    --
    Regards,
    Tom Ogilvy

    "cvach" <[email protected]> wrote in message
    news:[email protected]...
    > I have this code thus far. I want all of this information to be on the
    > same line but as of right now it buts it on two seperate lines. How
    > can I combine the codes and have them com in on the same line.
    >
    > Sub copy_1_Values_PasteSpecial()
    > Dim sourceRange As Range
    > Dim destrange As Range
    > Dim Lr As Long
    > Application.ScreenUpdating = False
    > Lr = LastRow(Sheets("Invoices")) + 1
    > Set sourceRange = Sheets("PO Form").Range("A44:G44")
    > Set destrange = Sheets("Invoices").Range("A" & Lr)
    > sourceRange.Copy
    > destrange.PasteSpecial xlPasteValues, , False, False
    > Application.CutCopyMode = False
    > Application.ScreenUpdating = True
    > End Sub
    >
    > Sub copy_3_Values_PasteSpecial()
    > Dim sourceRange As Range
    > Dim destrange As Range
    > Dim Lr As Long
    > Application.ScreenUpdating = False
    > Lr = LastRow(Sheets("Invoices")) + 1
    > Set sourceRange = Sheets("PO Form").Range("H44:H44")
    > Set destrange = Sheets("Invoices").Range("H" & Lr)
    > sourceRange.Copy
    > destrange.PasteSpecial xlPasteFormulas, , False, False
    > Application.CutCopyMode = False
    > Application.ScreenUpdating = True
    > End Sub
    >
    > Function LastRow(sh As Worksheet)
    > On Error Resume Next
    > LastRow = sh.Cells.Find(What:="*", _
    > After:=sh.Range("A1"), _
    > Lookat:=xlPart, _
    > LookIn:=xlFormulas, _
    > SearchOrder:=xlByRows, _
    > SearchDirection:=xlPrevious, _
    > MatchCase:=False).Row
    > On Error GoTo 0
    > End Function
    >




+ 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