+ Reply to Thread
Results 1 to 6 of 6

Search for specific word and offset and change value.

  1. #1
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Search for specific word and offset and change value.

    Hey guys,

    I'm pretty sure this is fairly easy, I have a working version but it can go wrong with my data so I'm looking for a version what wont go wrong.

    I need a macro to look at the range: Range("S1:S" & LastRowA)
    Every time it finds the text "CODE5" it needs to do the following:

    Please Login or Register  to view this content.
    Last edited by Hyflex; 12-21-2011 at 09:55 AM. Reason: Solved

  2. #2
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Search for specific word and offset and change value.

    Please Login or Register  to view this content.
    Will the above work?

    edit: Also if you want your .Offset values to work you have to start at S4.

    .Offset( # = row, # = column)

    So .Offset(-3, 2) changes the active cell -3 rows and +2 columns. That's why your code can't work for cell S1, S2, and S3.
    Last edited by 111StepsAhead; 12-21-2011 at 09:41 AM.

  3. #3
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Search for specific word and offset and change value.

    I totally forgot about using it in a for loop.

    I made a few minor changes and it works perfectly. My data starts on row 15 so x has been changed to 15 and also lastrowa has already been defined so I removed that part.

    I also added an x = x + 4 at the end of the changes to help speed it up and it now works splendidly.


    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Search for specific word and offset and change value.

    If you need to check every 4 values consider using the step command with the for loop. You can read about it here...

    http://www.ozgrid.com/VBA/for-loop-step.htm

  5. #5
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Search for specific word and offset and change value.

    It's not four, I just know when it finds one the next one won't be found in the next 4 rows

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Search for specific word and offset and change value.

    or

    Please Login or Register  to view this content.



+ 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