Posted to microsoft.public.excel.programming
|
|
Macro to populate next empty cell?
Hi Ouka
What this does is insert the selected date into the next available cell
in column B, from B2 to B65536 (I'm not really understanding why this
starts at B2 and not B1!)
It will find the first cell with data and if there is no data it is Cell B1
Range("B65536").End(x1Up)
It go one cell down
..Offset(1, 0).Select
Try this for a range
Sub testing2()
On Error Resume Next
Range("B8:B58").Cells.SpecialCells(xlCellTypeBlank s).Cells(1).Value = "Hi"
If Err.Number 0 Then
MsgBox "all cells are used"
Err.Clear
End If
On Error GoTo 0
End Sub
--
Regards Ron de Bruin
http://www.rondebruin.nl
"Ouka" wrote in message
...
Hi Ron,
Thanks for your reply. I do like what part of that macro does and I'll
be incorperating it into mine, but it's not quite what I'm looking for.
I need the user to click on a static icon that will insert the selected
date into the next available field.
What I have currently is:
Private Sub Calendar1_Click()
Range("B65536").End(x1Up).Offset(1, 0).Select
ActiveCell.Value = Calendar1.Value
Unload Me
End Sub
What this does is insert the selected date into the next available cell
in column B, from B2 to B65536 (I'm not really understanding why this
starts at B2 and not B1!)
Also, I don't understand is if I change
Range("B65536").End(x1Up).Offset(1, 0).Select
to
Range("B8:B58").End(x1Up).Offset(1, 0).Select
Why does the value still start at B2, go up to B8, then go back up to
B3 and stay on B3?
i.e. I click on my button with the calendar macro, and a date is filled
into B2. Click again, and it fills B3 .... up to B8. Click again after
that and it re-fills B3. And if I keep clicking, it keeps overwriting
B3.
I must really not understand the syntax because to me this statment
says this macro is to be applied over the range B8 to B58.
I have also tried substituting that Range command with:
Range("B8").Activate
Which inserts the date into B8 just fine. Problem is I've had no luck
in writing an If/Then/Else statement to check if the active field is
Null, and if not, move down a cell, recheck, etc until an empty cell is
found.
My next probelm is going to be ever worse. Corellating the dates
entered here into a calendar laid out in another workbook. Not looking
forward to that at all. But baby steps, baby steps. Have a lot to do
before I get to that point ~_^
--
Ouka
------------------------------------------------------------------------
Ouka's Profile: http://www.excelforum.com/member.php...o&userid=23988
View this thread: http://www.excelforum.com/showthread...hreadid=376075
|