How to replace other cell values in excel using VBA

How to replace other cell values in excel using VBA

This VBA enables you to replace cell values other than the specific ones. Refer below code for How to replace other cell values in excel using VBA

VBA Code:

Sub Replace()
Dim Setrng As Range
Dim i As String
'Talentnett Solutions - visit us at'
Set Setrng = Application.InputBox("Select Range", "Get Range", Type:=8)
i = "Abc" '[case sensetive] -This should be the value which you don't want to replace, rest all other cell value should be replaced'
For Each cell In Setrng
If cell.Value <> i Then cell.Value = "XYZ" 'This should be your New/specific value which you want to replace with other cell values'
Next cell
End Sub

Step 1 – Go to Excel
Step 2 – Right-click on the sheet tab>>View code or Press “ALT+F11”
Step 3  – Paste the above code in the VBA window and Press “Alt+Q”
paste macro code here
Step 4 – Save your excel file as a macro-enabled file (Press “F12” >> change Save Type as “Excel Macro-Enabled Workbook”)
Step 5 – Insert any shape – Insert>>Shapes
Step 6 – Right-click on that shape and assign that macro (refer below image)
How to Assign Macto to any shape
Step 7 – Select the data range and press “ok”
Cell values will be replaced.


Download Excel (128 downloads)

Read More:


  • comment-avatar

    When someone writes an piece of writing he/she maintains the idea of a user in his/her
    mind that how a user can understand it. So that’s why
    this paragraph is outstdanding. Thanks!

  • comment-avatar

    I used to be more than happy to seek out this web-site.I wished to thanks to your time for this wonderful read!! I undoubtedly having fun with every little little bit of it and I have you bookmarked to check out new stuff you weblog post.

  • Open chat
    Talentnett Solutions

    How may I help you today!

    Umesh Agarwal
    Contact - +91 - 7017544508
    Email -

    Cool Tips and Tricks Directly Delivered in your Inbox. Subscribe to our Newsletter.

    You have successfully subscribed to the newsletter

    There was an error while trying to send your request. Please try again.

    Talentnett will use the information you provide on this form to be in touch with you and to provide updates and marketing.