check criteria and run macro

  • Thread starter Thread starter pswanie
  • Start date Start date
P

pswanie

thanx bob ur code works...

but now how do i change it to go and check on sheet named "inputpage" for
row a and b?

im going to put a cmdbutton on about 10 or 12 sheets and need this macro to
then go and check on the "inputpage" for that word/number combination

and where do i tell it to a macro called editsheet if the number enterd is
correct?



much appreciated






Sub Test()
Dim mpRow As Long
Dim mpWord As String
Dim mpResult As Double

mpRow = Int(Rnd() * 25 + 1)
mpWord = Cells(mpRow, "A").Value

On Error Resume Next
mpResult = InputBox("provide a number for " & mpWord)
On Error GoTo 0
If mpResult <> 0 Then

If mpResult <> Cells(mpRow, "B").Value Then

MsgBox "Wrong"
Else

Cells(mpRow, "A").Value = ""
End If
End If
End Sub
 
You can add a with statement and put a period infront of the cell references

Sub Test()
Dim mpRow As Long
Dim mpWord As String
Dim mpResult As Double


with sheets("inputpage")
mpRow = Int(Rnd() * 25 + 1)
mpWord = .Cells(mpRow, "A").Value

On Error Resume Next
mpResult = InputBox("provide a number for " & mpWord)
On Error GoTo 0
If mpResult <> 0 Then

If mpResult <> .Cells(mpRow, "B").Value Then

MsgBox "Wrong"
Else

.Cells(mpRow, "A").Value = ""
End If
End If
end with
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top