View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
taco taco is offline
external usenet poster
 
Posts: 11
Default Entering value into cell via VB code if cell is empty

Hi Gary;

Thanks a lot for the help. It works, just one more problem. In case D9 is
full, next cell should be D10. Now it's moving to E9. I've tried .next
instead of .offset but result was the same. Any Idea??

Best Regards;

taco

"Gary Keramidas" wrote:

maybe something like this, but i'm not sure what you want to do when both cells
are populated

Sub ar1open()
With Range("D9")
If .Value = "" Then
.Value = Format(Time(), "hh:mm")
Exit Sub
ElseIf .Offset(, 1).Value = "" Then
.Offset(, 1).Value = Format(Time(), "hh:mm")
End If
End With
End Sub


--


Gary


"taco" wrote in message
...
Hi there everyone;

Again thanks a lot in advance for the time and help. This time the question
is;
I'm trying to write a code which should check the cell if it's empty or not.
If it's empty, code should write the current time into cell. If the cell is
not empty, code should go to the other cell to check if that one is empty or
not.

Here is my unsuccessful code;

________________________________________
Function zaman()
ActiveCell = Time()
ActiveCell.NumberFormat = "hh:mm"
End Function
__________________________________________

Sub ar1open()

Range("D9").Select
If D9 = "" Then
D9 = zaman
Else
Range("D10").Select
If D10 = "" Then
D10 = zaman
End If
End If

End Sub

Best Regards.