View Full Version : Solved: ActiveCell Property Question

12-06-2007, 09:55 AM
Hi, Folks...

I'm trying to create a macro where the user can put their cursor anywhere within a row, and then click a button which will populate various information on that row.

I'm trying to use the activecell property to get information into the macro to tell it what row to put the information on. Please see the following code:

Sub EmptyReturnStamp()
Dim focusCell, targetRow As String

focusCell = ActiveCell.Value 'gets the value of the active cell
targetRow = Mid(focusCell, 2, 4) 'pulls the row information from the cell reference

Sheets("Gate Control").Cells(targetRow, 3) = "RETOUR BOUTEILLES VIDES"

End Sub

When I do this, I get a mismatch error on the last line of code (before End Sub), and when I hover over the variables, nothing is being stored in focusCell.

Any suggestions?

Thanks!!!! :)

12-06-2007, 10:42 AM
Shouldn't it be ActiveCell.Row?

Or do you actually have an address in the active cell that you want to use?

12-06-2007, 10:46 AM
Norie...not sure - I kind of have to leave it open, as the user may select any cell along the row as the "click on" point. Basically, the user puts the focus on a cell in a row, hits the button, and information populates on various cells within that row - I only have one statement included for the purposes of posting here.

12-06-2007, 10:47 AM
Essentially I'm just looking to put the address of the active cell into a variable - so, if the active cell is A15, I want the variable "focusCell" to equal "A15", as a string.

12-06-2007, 11:10 AM
Well to get the row use ActiveCell.Row.

It returns the row property of the range, in this case the active cell.

12-06-2007, 11:15 AM
Awesome, thanks!!! I knew it had to be something simple...

Thanks again!