I am new to VBA, and am an extremely bad coder to begin with.
Essentially what I need to do is take a product key value, compare that key value in a list of thousands, and replace that product key value with the new updated value.
I am a picture learner so this is what I am working with extremely simplified:
V
V
I have some code that I am currently writing, and have tried looking up a lot of different built in functions that I can work with, but I am really lost.
Sub SwapNumbers()
Dim OldNumber As Integer
Dim myrange As Range
Dim NewNumber As Integer
' Select Current Cell
OldNumber = ActiveCell.Value
My first main question, is how do I set a variable to be able to cover a row range so large? I know I will have to change the variable type if I change it. But I am thinking is it possible to maybe do a loop that might be able to run through every row in a certain column until it finds the number then stops?
'Compare Cell Value (Old Number) to List of Numbers (Col 1)
Set myrange = Worksheets("Sheet 2").Range("A2:A1712")
For Each cell In myrange
If IsNumeric(Application.Match(OldNumber, myrange, 0)) Then
NewNumber = myrange.Value
End If
Next
If that is the case, once I find that cell, how do I save it to then make sure I can move over to a new column to find the new product key value? 'If found Old number match (Col 1) jump to New number (Col 2)
And I guess this next part is pretty simple, I just have to figure out the correct syntax....
'Input New number (Col 2) into selected cell
End Sub
I hope this makes sense? I feel like I am vastly overcomplicating this. Or maybe not making it complicated enough. Who knows.


