+ Reply to Thread
Results 1 to 5 of 5

Coyping results in Run-TIme Error 424, Need help to edit code

  1. #1
    Registered User
    Join Date
    04-05-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Coyping results in Run-TIme Error 424, Need help to edit code

    Hye guys, this maybe a newbie problem, I dont know. But need help editing my code below:-

    The code works up until the last line, the msgbox works and shows the value i needed to copy, but the code does not copy the value stored in "thedate2", instead it shows a "an object required error".

    Need something like " thedate2.value.copy Range("g1") ", obviously this does not work.


    Please Login or Register  to view this content.

    Please help out, Thanks.

  2. #2
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Coyping results in Run-TIme Error 424, Need help to edit code

    PHP Code: 
    Sub tdateplus1()
    Dim thedate As Rangethedate2 As Range

    Set thedate 
    Worksheets("sheet1").Cells(Rows.Count"a").End(xlUp)
     
    Set thedate2 thedate.Offset(-1

    If 
    Not thedate2 Is Nothing Then
       MsgBox thedate2
    .Address

       thedate2
    .Copy Destination:=Range("g1")
     
    End If
    End Sub 
    Last edited by Sa DQ; 08-01-2012 at 10:31 PM.

  3. #3
    Registered User
    Join Date
    04-05-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Coyping results in Run-TIme Error 424, Need help to edit code

    Hi Sa DQ,

    Thanks for the code, but it is not what I need. I'll be more specific,

    Thedate and thedate2 are continous dates:

    e.g thedate =12/1/2012
    thedate2 =13/1/2012

    Therefore, in the cell G1, the date should be 13/1/2012. Your code returned back 12/1/2012.

    The macro is to place the next date after the date value of the last row in column a, into range G1.

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Coyping results in Run-TIme Error 424, Need help to edit code

    Hi

    How about

    Please Login or Register  to view this content.
    rylo

  5. #5
    Registered User
    Join Date
    04-05-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Coyping results in Run-TIme Error 424, Need help to edit code

    Hi Rylo,

    I tried using the exact method before, but the expression "range ("G1").value" has to be a named variable such as thedate2, so i can call it in another macro in another workbook , also the "value + 1" in the line cells(rows.count,1).end(xlup).value + 1 results in an error when I try to pull "thedate2".

    Thanks a lot for the effort anyway.

    Luckily I found a solution after several trial and errors. I'll share it here:-

    Please Login or Register  to view this content.
    Thanks Rylo and Sa DQ for helping out.

+ 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