How do I get the current activated cell

fernandoagf
09-04-2009, 03:28 PM
Hello you all,

How do I get the cell that is high-lighted?

This is my problem:

Let's say that the current activated cell is B5, then I when I play my MACRO I want this activated cell (B5) to change its current value to 6.5.

Now if the cell C5 is activated, I want to have its value changed to 6.5.

So, my problem is, how do I get the current active cell?

Another question: Let's say that the C6 cell is activated, how do I refer to the cell that is on its left side (C5)? How do I program C6 - 1 in VB?

Thanks a lot.

Fernando

EmptyVessel
09-04-2009, 04:45 PM
Hi fernandoagf, Welcome to the forum.

If you are asking a question about Excel then you should really post it in the 'Office | Excel' forum area.

Regarding you question: How about the ActiveCell() method?


Option Explicit

Public Sub cmdWrite_Click()
ActiveCell = 6.5
Cells(ActiveCell.Row, ActiveCell.Column - 1) = 5.5
End Sub

fernandoagf
09-05-2009, 11:28 AM
Hello Vessel,

Sorry about choosing the wrong area. Form my next doubt on Iīll start posting there.

Thanks for the help but I still wasnīt able to make it work.

This is the code that EXCEL generated for me:

Sub Macro2()
Range("G8").GoalSeek Goal:="H8", ChangingCell:=Range("F8")
End Sub

Now, what I want is:
1) Change 'G8' for the current active cell
2) Change 'H8' for the cell that is on the right hand side of active cell
3) Change 'F8' for the cell that is on the left hand side of active cell

How do I do this?

Thanks a lot.

Fernando.

JSTKwan
09-06-2009, 08:37 AM
This is off of the top of my head:

activecell.GoalSeek Goal:=activecell.offset(0,1), ChangingCell:=activecell.offset(0,-1)

fernandoagf
09-06-2009, 08:57 AM
Thank you! Thatīs just what I was looking for!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum