run VBA in a module

chubbers001

New Member
Joined
Nov 4, 2011
Messages
17
ABCDE
1Test DateDate Last TestedOld numberNew Number
2Item 114-Jul-18124532665
4Item 215-Jul-189876541456
3Item 316-Jul-18654731846
4Item 512-Sep-1865411546
5Item 613-May-18456711533

<tbody>
</tbody>

Hi All, I am in desperate need of help. I am new to VBA but I have tried to write a code and I really dont know how to start. I am looking for a code that will open an input box and look up "New Number". Once a value of E.G 1456 has been put into the input box, it will look up the page and find a match, E4. Then it will copy E4 and paste into D4, and opens up another input box that will ask for a New Number and once the new number has been typed into the input box, it inserts the "New Number" into E4. If no match is found, then "No Match Found".
My TAB is called "Equip Sheet ABC" if this helps.
This will be assigned to a Button from Form Control.
I would really appreciate any assistance with this, and thanks for reading.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
See if this works for you.
Code:
Public Sub Find_and_Update_Number()

    Dim foundRow As Variant
    Dim inputNumber As String
    
    inputNumber = InputBox("Enter number to search for")
    If inputNumber <> "" Then
        foundRow = Application.Match(CLng(inputNumber), ActiveSheet.Columns("E"), 0)
        If Not IsError(foundRow) Then
            ActiveSheet.Cells(foundRow, "D").Value = ActiveSheet.Cells(foundRow, "E").Value
            inputNumber = InputBox(inputNumber & " found in E" & foundRow & vbCrLf & vbCrLf & "Enter new number")
            If inputNumber <> "" Then
                ActiveSheet.Cells(foundRow, "E").Value = inputNumber
            End If
        Else
            MsgBox "No match found - " & inputNumber & " not found in column E"
        End If
    End If

End Sub
 
Upvote 0
See if this works for you.
Code:
Public Sub Find_and_Update_Number()

Hi John_w;5104619
I put your code into my spread sheet and it worked perfectly.
You are a life saver, thanks you for your fast reply.
I much appreciate your help
Have a nice Day
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,568
Members
448,972
Latest member
Shantanu2024

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