VBA search and update help

Adam88

New Member
Joined
Dec 12, 2017
Messages
16
Hi,

Wasn't sure how to correctly title this question but here goes;

I would like to know how to find the contents of a cell (which I am currently doing with a worksheetfunction.Vlookup method), copy the contents to an integer (or other number) variable, add another integer to it (based on a userform textbox entry) and then paste the new value back into the original cell.

I can somewhat accomplish all apart from the last bit which is where I'm unsure of the correct approach.

Thanks
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
Substitute your values for 25 and 100 in the code and change the search range to your actual range.
Code:
Sub t()
Dim xVal As Long, fn As Range
xVal = 25
Set fn = Range("A2:A100").Find(xVal, , xlValues) 'Range and values are arbitrary, require substitution
 If Not fn Is Nothing Then
     fn = xVal + 100
 End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,307
Messages
5,600,869
Members
414,411
Latest member
Snowmanaus

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
Top