Consulting

Results 1 to 2 of 2

Thread: Change value of the cell below based on criteria

  1. #1
    VBAX Regular
    Joined
    May 2009
    Posts
    76
    Location

    Change value of the cell below based on criteria

    I'm attempting to write code to change the value of the cell below when the cell above matches "Amount X's of" in column G. However the range can expand or collapse based on the amount of rows the user enters.

    Dim FoundCell As Range
    Set FoundCell = Range("G2:G100").Find(What:="Amount X's of")
    Do Until FoundCell Is Nothing
    ActiveCell.Offset(1, 0).Value = "25"
    Set FoundCell = Range("G2:G100").FindNext
    Loop

    Amount of X's of
    1111 (change this)
    1111 (do not change)
    1111 (do not change)
    Amount of X's of
    0000 (change this)
    1111 (do not change)
    1111 (do not change)

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]


    Dim FoundCell As Range
    Dim lastrow As Long

    With ActiveSheet

    lastrow = .Cells(.Rows.Count, "G").End(xlUp).Row
    With Range("G2:G" & lastrow)

    Set FoundCell = .Find(What:="Amount X's of")
    Do Until FoundCell Is Nothing
    FoundCell.Offset(1, 0).Value = "25"
    Set FoundCell = .FindNext(FoundCell)
    Loop
    End With
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •