Get Active Sheet

  • Thread starter Thread starter scott
  • Start date Start date
S

scott

I've got the worksheet and cell hard-coded below. What's the syntax to
replace "sheet1" withe name of the active worksheet and replace "a7" with
the active cell?

I'd like to be able to assign both above mentioned values to variables like
"pageActive" and "cellActive" and then be able to insert those variables
into the code below. I'm familiar with Access VBA, but don't know how to
treat Excel's vba variables and quotes.

CODE:

Worksheets("sheet1").Range("a7").Value
 
I'm not just 100% sure what you want but here goes

dim strActiveSheet as String
dim strActiveCell as String

strActiveSheet = ActiveSheet.Name
strActiveCell = ActiveCell.Address
Worksheets(strActiveSheet).Range(strActiveCell).Value
 
that get's it.

Jim Thomlinson said:
I'm not just 100% sure what you want but here goes

dim strActiveSheet as String
dim strActiveCell as String

strActiveSheet = ActiveSheet.Name
strActiveCell = ActiveCell.Address
Worksheets(strActiveSheet).Range(strActiveCell).Value
 

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