+ Reply to Thread
Results 1 to 3 of 3

VBA Copying and Pasting from One Sheet to Another

  1. #1
    Registered User
    Join Date
    06-09-2010
    Location
    Verwood, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    VBA Copying and Pasting from One Sheet to Another

    If someone could help that would be great!! I'm quite new to the whole VBA thing!

    everything on here works up until the 'Copy Destination:=ThisFile.ThisSheet.Range("rngJourn_Nos")' part (highlighted in yellow). I keep getting the error *runtime '438' Object doesn't support this property or method.

    I'm not sure why. I have tried all sorts of things to try and resolve the issue along with trailing through numerous forums?

    Private Sub JournalReg_Click()
    Dim ThisFile As Workbook
    Dim JournReg As Workbook

    Dim ThisSheet As String

    Set ThisFile = ThisWorkbook

    ThisSheet = ActiveSheet.Name

    Dim Sht As Worksheet
    Dim JnlReg As String
    Dim Answer As String

    JnlReg = Range("rngFile_JnlReg").Value

    For Each Sht In ThisWorkbook.Worksheets
    Sht.Unprotect
    Next Sht

    Sheets("Jnl Vouch").Select

    If Company.Text = "" Then
    MsgBox "You must enter a Company"
    Exit Sub
    End If
    Range("rngCo") = Company.Text

    Range("rngEntry") = EntryDate
    Range("rng_pdate") = PostingDate

    Workbooks.Open Filename:=JnlReg
    Range("A65536").End(xlUp).Offset(1, 12).Select
    Answer = MsgBox("The next JV Ref is " & Selection & ". Do you want to use this JV Ref?", vbYesNo + vbQuestion)
    If Answer = vbNo Then Exit Sub
    If Answer = vbYes Then Selection.Copy Destination:=ThisFile.ThisSheet.Range("rngJourn_Nos")
    End Sub

    Any Help would be appreciated

  2. #2
    Forum Contributor johnjohns's Avatar
    Join Date
    11-19-2007
    Location
    Dubai, UAE
    MS-Off Ver
    2003 and 2007
    Posts
    526

    Re: VBA Copying and Pasting from One Sheet to Another

    I think you have to activate the first w.book
    by
    Please Login or Register  to view this content.
    and then paste directly to the range without mentionaing the sheet name (if the range name is not local)


    ps

    To understand your issue better please provide a sample w.book. Also please read the forum rules and use tags whereever necessary

    rgds

    johnjohns

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA Copying and Pasting from One Sheet to Another

    You should declare ThisSheet as a worksheet and you can then use it as you have.

    Please Login or Register  to view this content.

    Please use code tags when posting code.

    Dom
    Last edited by Domski; 09-29-2010 at 10:03 AM.
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

+ 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