Discussion Locked

Excel Macros

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have an input box gathering a loan number. These variable contents are entered into cell "b45" on sheet "Return item". The cell has a definedname of "LoanNumber"

>Dim Message, Title, MyValueB
>Message = "Enter the Loan number for the item(s)you wish to return."
>' Set prompt.
>Title = "Return Loan Item" ' Set title.
>' Display message, title, and default value.
>MyValueB = InputBox(Message, Title)
>Sheets("Macros").Select
>Range("B45:B45") = MyValueB

This all works fine, however when I try and find this loan number on the register sheet I am currently using the following

>Sheets("Register").Select
>Columns("A:A").Select
>Selection.Find(What:="3", After:=ActiveCell, LookIn:=xlValues,
>LookAt:=_
>xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
>MatchCase:=False) _
>.Activate

The above is hard coded to find loan number "3" as an example. I am unable to make the find function work using the variable input obtained using the information obtained from the input box.

1 reply

by gopindia

Sub GOPIK()
Dim Message, Title, MyValueB
Message = "Enter the Loan number for the item(s) you wish to return."
' Set prompt.
Title = "Return Loan Item" ' Set title.
' Display message, title, and default value.
MyValueB = InputBox(Message, Title)
Sheets("Sheet1").Select
Range("B45:B45") = MyValueB
Sheets("Sheet1").Select
MyValueB = InputBox(Message, Title)
Sheets("Sheet1").Select
Columns("A:B").Select
Selection.Replace What:=MyValueB, Replacement:="success", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False

End Sub

This discussion is closed to new replies.