Forum Discussion
ikedalim
Feb 06, 2022Copper Contributor
Move cursor to specific worksheet in Excel
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").Activate
Sheets("Tmth").Range(Tday & Tstore).Select
End Sub
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.
4 Replies
What kind of values do E3, E4 and E5 contain?