how to change the code to do find the value and replace value
hi
i have this code from this forum but i need to change to do the following
to change the value of column
H = c*.88,
I =c*0.12,
J=sum(H:I)
on same row which changed by input value
PHP Code:
Sub changevalue2() Dim r As Range, rng As Range, r1 As Range, r2 As Range, s As String, c As String
Set r = Range("G5", Range("G580").End(xlUp))
r.Offset(0, 8).ClearContents
s = InputBox("What to find and change?") c = InputBox("change with")
With Range("G5") .AutoFilter Field:=7, Criteria1:=s
On Error Resume Next
Set rng = r.Cells.SpecialCells(xlCellTypeVisible) 'if no items found
If rng Is Nothing Then MsgBox "No records found" .AutoFilter Exit Sub End If r = c '<----- its working perfectly as per my need r1.Offset(0, 8) = c * 0.88 '<----- not working r2.Offset(0, 9) = c * 0.12 '<----- not working
Re: how to change the code to do find the value and replace value
Hi jay11
Without seeing your actual workbook, it's difficult to say. However, there is no line of code that changes the value of either H or I. If you're expecting this code
If this is what you're trying to accomplish, reverse the change you made to Set r and make the reference change illustrated above. Otherwise, post a copy of what you have and what you'd like it to be and I'll see if I can help.
John
Re: how to change the code to do find the value and replace value
thanks buddy
it work great but can u change the code so it work only on the "Names" sheet only
since there r so many sheet in the wb
i try to change like this but it did not work
Re: how to change the code to do find the value and replace value
Hi jay11
If you still have the old code loaded, enter 999.99 in s = InputBox("What to find and change?") and 888.88 in c = InputBox("change with") and see what happens.
Re: how to change the code to do find the value and replace value
hi John
thanks this new code is changing value and work .but now it add new records at last row
here i am attaching the wb with both code and commented last row.
thanks for helping otherwise i be in trouble.
Re: how to change the code to do find the value and replace value
Hi jay11
I think we've worked this out. If you're happy with the solution, please mark your post as solved. A click on the scales is appreciated if you feel appropriate.
Bookmarks