vba newbie - explanation

  • Thread starter Thread starter patti
  • Start date Start date
P

patti

I am just starting to use vba w/ excel. Could someone perhaps please explain
the following code:

sFilename = Right(Me.Cells(i, "A").Value, Len(Me.Cells(i, "A").Value) -
InStrRev(Me.Cells(i, "A").Value, "_"))


i know that the functions "Right", "Len", "In Str Rev" will become the
sFilename which is called elsewhere; i am befuddled by the (Me.Cells(i,
"A").Value).

thanks for helping me get jumpstarted.

patti
 
Me refers to the containing object, which is undoubtedly the sheet in this
case. So this code is within a sheet class module. Cells(i,"A") is just
picking up the cell in column A, row i.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Me is the thing that holds the code.

In your case, I bet that this code is behind a worksheet.

So me.cells(i,"A").value
is the value in the cell in column A, Row i

Me can be used in the ThisWorkbook module, too. In that case, it refers to the
workbook that owns the code. Equivalent to ThisWorkbook.

Me can be used behind a userform, too.

Me.combobox1.listindex = -1
would clear combobox1 on the userform that owns the code.
 

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