+ Reply to Thread
Results 1 to 3 of 3

Paste value to cell relative to FIND result

Hybrid View

  1. #1
    Registered User
    Join Date
    08-17-2012
    Location
    Dundee
    MS-Off Ver
    Excel 2010 64 Bit
    Posts
    15

    Paste value to cell relative to FIND result

    Hi Folks,

    I am trying to figure out the VBA code to paste a value from a userform in the cell 20 columns to the right of a cell found using a FIND call. I have the FIND function returning the correct cell but am unsure how to either

    a) Return the cell address of the result, eg (1,1), so I can increment the value or
    b) Use a relative reference to the result cell to designate the cell to be pasted to.

    From the searches on the topic I have only found how to select ranges using the FIND result as the first cell, not how to shift to a different cell using the result as a starting point.

    Any help much appreciated.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Paste value to cell relative to FIND result

    Hi, GFIJames,

    maybe proceed like this (search in Sheet1 Column A for the string from textbox1 on the Userform):
    Dim rngFound As Range
    Set rngFound = Sheets("Sheet1").Range("A:A").Find(What:=Textbox1.Value, _
        SearchOrder:=xlByColumns, _
        SearchDirection:=xlNext, _
        MatchCase:=True, _
        SearchFormat:=False)
    
    If Not rngFound Is Nothing Then
      rngFound.Offset(0, 20).Value = "just a test"
    End If
    
    Set rngFound = Nothing
    Ciao,
    Holger

  3. #3
    Registered User
    Join Date
    08-17-2012
    Location
    Dundee
    MS-Off Ver
    Excel 2010 64 Bit
    Posts
    15

    Re: Paste value to cell relative to FIND result

    Cheers Holger,

    Does the job wonderfully

    Many thanks

+ 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