PDA

View Full Version : ActiveCell not working the way i'd expect



chamster
09-03-2007, 12:25 AM
Running this code


With ActiveSheet
.Cells(10, 10).Select
.ActiveCell.Value = 12345
MsgBox "value: " & .ActiveCell.Value
End With


i would expect the computer to select the cell on the active sheet and then fill in the value 12345 into it. For some reason, the cell gets selected BUT the value doesn't. For some reason, no message box is displayed either. What reason might that be?

Bartek
09-03-2007, 12:35 AM
Hi,

ActiveCell is a property of Application object, not ActiveSheet. Just try:


With ActiveSheet
.Cells(10, 10).Select
ActiveCell.Value = 12345
MsgBox "value: " & ActiveCell.Value
End With

mdmackillop
09-03-2007, 02:20 AM
But why select?


With ActiveSheet.Cells(10, 10)
.Value = 12345
MsgBox "value: " & .Value
End With