[RESOLVED] Getting current Cell Address in Excel
I'm new to VBA and Office programming. I have an Excel spreadsheet that contains a command button. I want this button to insert a literal value into specific cells only. My cursor will be setting on the targeted cell and then I will click on the command button to insert the literal value. My problem is, how do I know which cell I'm setting on? Is there a function that can tell me what cell my cursor is occupying?
Thanks,
Re: Getting current Cell Address in Excel
activecell
or activecell.address to return the location
Re: Getting current Cell Address in Excel
The ActiveCell refers to current cell. So you can use ActiveCell.Address to get the address of current cell.
Re: Getting current Cell Address in Excel
What I am trying to do is this
Code:
For x = 6 to 25
If ActiveCell.Address Then
Cells(x, 3) = "PAID"
End If
Next x
I have a range of cells starting at row 6 column 3 (it will always be column 3). If the cursor is setting on one of these row/columns, then I wish to be able to click a button and have it insert "PAID" in the cell.
Re: Getting current Cell Address in Excel
Code:
For x = 6 to 25
If ActiveCell.Row = x And ActiveCell.Column = 3 Then
ActiveCell.FormulaR1C1 = "PAID"
End If
Next x
Re: Getting current Cell Address in Excel
Better still:
Code:
If ActiveCell.Column = 3 Then
If ActiveCell.Row >= 6 And ActiveCell.Row <= 25 Then
ActiveCell.FormulaR1C1 = "PAID"
End If
End If
You don't need to loop thru the cell in this way. :)
Re: Getting current Cell Address in Excel
that worked Pradeep1210...thanks!!!!