Move cursor to specific worksheet in Excel

Occasional Contributor

If I have multiple worksheets (Jan to Dec & Main page) and in my main worksheet, user is allow to key in which month's worksheet to go to and error message popped up (type mismatch) when running the VBA code below. Please advice, thanks.


Sub moveToCell()
Dim Tday As Integer
Dim Tstore As Integer
Dim Tmth As Integer

Tday = Sheets("Main").Range("E3").Value
Tstore = Sheets("Main").Range("E4").Value
Tmth = Sheets("Main").Range("E5").Value

Sheets("Tmth").Range(Tday & Tstore).Select
End Sub

4 Replies


What kind of values do E3, E4 and E5 contain?

E3 & E4 are numeric and E5 alphanumeric.
best response confirmed by ikedalim (Occasional Contributor)


If Tday (E3) and Tstore (E4) are numeric, Range(Tday & Tstore) is not valid.

For example if E3 = 12 and E4 = 37, Tday & Tstore would be "1237". Range("1237") results in an error.

Yeah, thanks for the advice, I've managed to solve it.