Sunday, November 14, 2010

In writing a Macro in Excel the VB is referencing the data in the cell and not the cell?

In writing a Macro in Excel the VB is referencing the data in the cell and not the cell. To be able to reuse this macro, I need the VB code to reference data in the cell (so it can be dynamic), any help is appreciated.



so how do I ref. a Cell in VB?In writing a Macro in Excel the VB is referencing the data in the cell and not the cell?
There is various way in referencing to a cell value without directly involve its address, here's some ways



To refer to the content of the cell value where the cursor locate

ActiveCell.Value



To get the value 2 rows down and 3 columns right of the ActiveCell

ActiveCell.Offset( 2,3).Value



Or in a group of select the cells, say A1:C3, to get the value of the center cell of the 9

Selection(5).Value



Or in case of unique value on a sheet, say get the address of cell contains 100

ActiveSheet.Cells.Find(100, LookIn:=xlValues, Lookat:=xlWhole).Address



So it's depends on what's your requirements and the routine you plan to deploy



Please contact for more info.

No comments:

Post a Comment