+ Reply to Thread
Results 1 to 8 of 8

Find string and offset copy

Hybrid View

  1. #1
    Registered User
    Join Date
    06-06-2007
    Location
    NYC, NY
    Posts
    66

    Find string and offset copy

    Hi hi,

    I am writing a macro to do many things but one task is to find the zip code on a sheet written zip in column a and the actual 5 digit code in column b. Then copy the # and paste it on another sheet in a specific cell.

    Unfortunately the below code does not work. What is wrong with my find statement?

    Thanks,
    ~RUTH~

    Sub test()
    
        Sheets("data").Select 'Get data from data sheet
        Cells.Find ("zip")  'Find zip code data
        ActiveCell.Offset(0, 1).Copy    'Copy zip code next to label zip cell
        Sheets("Tool").Select 'Paste to Tool sheet
        Range("D10").Select  'Select cell to paste to building description area
        ActiveSheet.Paste   'Paste building zip
    
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    Try this:
    Sub test()
    'Get zip from Data sheet & Copy
        Sheets("data").Cells.Find("zip").Offset(0, 1).Copy
    'Paste to Tool sheet
        Sheets("Tool").Range("D10").PasteSpecial
        Application.CutCopyMode = False
    End Sub

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    or maybe

    Sheets("Tool").Range("D10").Value = Sheets("data").Cells.Find("zip").Offset(0, 1).Value
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Registered User
    Join Date
    06-06-2007
    Location
    NYC, NY
    Posts
    66

    Thumbs up Thank you!

    Thanks for both your responses! VBA noob your simple 1 liner worked perfectly. I always record my macros and excel uses so many steps. It is nice to see real programing. Thanks again!

    ~RUTH~

  5. #5
    Registered User
    Join Date
    06-06-2007
    Location
    NYC, NY
    Posts
    66

    Exclamation .value vs link?

    What if instead of the value to be the same you wanted it to ref the other cell like =A1 not the value of A1.

    ~RUTH~

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Try this, untested:

    Sheets("Tool").Range("D10").Formula = "=" & Sheets("data").Cells.Find("zip").Offset(0, 1).Address

+ 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