Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fine tuning Input Box I am using the following macro: Sub HomeScore() iRow = Inp

ID: 640716 • Letter: F

Question

Fine tuning Input Box

I am using the following macro:

Sub HomeScore()
iRow = InputBox("Which row?")
iText = InputBox("Home score")
Cells(iRow, 2).Value = iText
iText = InputBox("Away score")
Cells(iRow, 6).Value = iText
End Sub

Rather than having a row number input, I would rather have a game #. The game's are listed in a range B10:B54. How can I identify that using the same kind of macro? This macro works brilliant but would be better using game number rather than row number.

Also, the input is always a number (whole number, no decimals) rather than text, but cells are formatted as "General", does that matter?

I borrowed this macro and seems to work fine, just want to fine tune it.

Thanks !!

Explanation / Answer

Hi..

Hi,

I left this very simple with no error checking but it now fins the game number in B10:b45

Sub HomeScore()
Dim TheRow As Long
Dim iGame As Long, iText As Long
iGame = InputBox("Which Game?")
TheRow = Application.Match(iGame, Range("B10:B25"), 0) + 9

iText = InputBox("Home score")
Cells(TheRow, 5).Value = iText
iText = InputBox("Away score")
Cells(TheRow, 6).Value = iText
End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote