using VBA to lookup a row that contains a value and change the contents in one cell

pcholka

New Member
Joined
Jan 27, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a data table like a checkbook register. I've written several Macros that allow me to edit the table from a different worksheet using a form (add data, look up data, delete a row in the table, etc.). I want to change the delete row functionality to a void functionality.

Every row has an ID number. I use the following string to lookup the ID number and delete the row.
Set Rng = TransIdCol.Find(What:=SearchValue, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False)
If Not Rng Is Nothing Then
Rng.EntireRow.Delete

I want to take the current value in column I of the row it finds and replace it with "void"

I am struggling finding a string to replace "Rng.EntireRow.Delete" to do that.

*credit to TeachExcel.com for the string I am currently using.*
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Replace a value in a cell of a row - Idiot Proofing Forms Series | TeachExcel.com
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
How about
VBA Code:
If Not Rng Is Nothing Then
Range("I" & Rng.Row).Value = "Void"
 
Upvote 0
It works when I run it from the VB editor. Thank you! When I run it from the button I created and linked to the Marco in another worksheet, it does not.
 
Upvote 0
Which col is the TransId column?
 
Upvote 0
Ok, how about
VBA Code:
If Not Rng Is Nothing Then
Rng.Offset(, 8).Value = "Void"
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,011
Messages
6,122,680
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top