1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Using Offset in Excel VBA to Return date frm another cell

Discussion in 'Business Applications' started by gjrobbins, Jan 27, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. gjrobbins

    gjrobbins Thread Starter

    Joined:
    Jan 25, 2010
    Messages:
    30
    Hi

    I am trying to get a date value from one sheet to populate another sheet using the offset function.

    Using:

    Range(Selection, Selection.End(xlDown)).Offset(0, 3)= " (need to show date here from another sheet) "

    Any help would be much appreciated..

    Thanks
     
  2. Sponsor

  3. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,436
    If the location of date on the other sheet's static, just:

    Range(Selection, Selection.End(xlDown)).Offset(0, 3) = Sheets("Sheet2").Range("A1")

    (e.g.).
     
  4. gjrobbins

    gjrobbins Thread Starter

    Joined:
    Jan 25, 2010
    Messages:
    30
    Hi Bomb #21

    Thanks for your help again - this works great but shows the format as numbers - is there a way of forcing the date format to show?
     
  5. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,436
    There's a problem with pre-formatting the "target area" as date format?

    [re "works great", the key to working with "remote" sheets is "explicit" referencing -- Sheets(SheetName).Range(Address)]
     
  6. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,436
    Macro Recorder is your friend. ;)

    Sub test()
    Range(Selection, Selection.End(xlDown)).Offset(0, 3) = Sheets("Sheet2").Range("A1")
    Range(Selection, Selection.End(xlDown)).Offset(0, 3).NumberFormat = "dd/mm/yy"
    End Sub
     
  7. gjrobbins

    gjrobbins Thread Starter

    Joined:
    Jan 25, 2010
    Messages:
    30
    Excellent - Works great

    Is there a way of adding on a Vlookup function onto this Offset string also?

    Ie how can I make it calculate and put the result in the offset cell

    Thankks
     
  8. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,436
    You lost me. More info required.
     
  9. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/897987