I was troubled by the following code
Dim xTRrow as Integer
Dim xTitle as String
Dim xSht as Worksheet
xTRrow = xSht.Range(xTitle).Cells(1).Row
I wonder what the last line does. Especially, the .Row
. In case as such, how do can I run the VBA code line by line to find out what a specific line of code does? I guess something is off with the code. I've tried to display xTRrow
which should be an integer. But nothing jumps on the screen. I wonder what the last option .Row
does.
In addition to using F8
to step through the code, you can use debug.print
to display the values of relevant variables before and after the given line. That said as you use VBA, you will be able to recognize what object and method is. Assuming the code works fine and all variables and objects were dimmed and set properly:
xSht.Range(xTitle).Cells(1).Row
break down as follows:
xSht
: variable containing a sheet (which sheet we don't know as that part of your code is missing in your question)
xTitle
: probably the name of a named range
(which range we don't know as that part of your code is missing in your question)
Cells(1)
: Cell no; 1
of the above mentionned named range
Row
: the row of the cell in question
So xTRrow
should be the row number of the cell in question. (BTW, it really should be Dim
med as Long
as Excel can have more rows than Integer
allows for