Note that there are some explanatory texts on larger screens.

plurals
  1. POFind and replace excel VBA trouble
    primarykey
    data
    text
    <p>I am currently working on a Excel VBA project in which I have created a button to find and replace the value in the worksheet depending on the user input, where user will provide a new hardware name, a quantity and the sheet name in which the new value needs to be updated. The hardware name is a unique value, so the update of the quantity should happen depending on the hardware name.</p> <p>The problem I am facing is that, when I try to update the values, the hardware name is getting updated properly but where as while updating the quantity it is not only updating the quantity of that particular hardware name but is updating all the quantity that matches the old quantity.</p> <p>Here is how the code looks like:</p> <pre><code>If .ComboBox1.Value &lt;&gt; vbNullString Then sName = .ComboBox1.Text 'is combobox name If Len(.OldHW.Value) &gt; 0 And Len(.NewHW.Value) &gt; 0 Then sOldText = .OldHW.Text 'OldHW and NewHW are textbox names sNewText = .NewHW.Text With Worksheets(sName) .Cells.replace what:=sOldText, Replacement:=sNewText, LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False End With End If If Len(.Oldqty.Value) &gt; 0 And Len(.Newqty.Value) &gt; 0 Then qOldText = .Oldqty.Text qNewText = .Newqty.Text With Worksheets(sName) .Cells.replace what:=qOldText, Replacement:=qNewText, LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False End With End If End If End With </code></pre> <p>Please any input will be greatly appreciated...</p> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload