PDA

View Full Version : fill down code help



RBCrackley
10-12-2007, 10:20 AM
I am using .filldown as part of a macro. I use it on several sheets of the same workbook and I'm having a problem with one worksheet. Normally, I have more than row of data, but for now on that sheet I only have one row. The formula should fill down to the last row of data, which it does, except in the case of where there is only one row and then it fills to the end the worksheet and I get a debug message. How can this be corrected? Thanks!

RonMcK
10-12-2007, 10:31 AM
Can you post a copy of the worksheet that exhibits the problem?

Thanks,

Ron
Orlando, FL

RBCrackley
10-12-2007, 11:11 AM
Thanks. I've tried several times, but my file is not uploading. Here is a copy of the code. . I don't know if that helps without atually seeing the workbook. I could email to you, if you wouldn't mind.

Select Case ActiveCell.Column
Case 1 ' Can't go left... based on data to Right
With ActiveCell(1, 2)
Range(.Item(1), .End(xlDown)).Offset(0, -1).FillDown
End With

Case Is > 1
With ActiveCell(1, 0)
Range(.Item(1), .End(xlDown)).Offset(0, 1).FillDown
End With
End Select
Range("O2").Select
Select Case ActiveCell.Column
Case 1 ' Can't go left... based on data to Right
With ActiveCell(1, 2)
Range(.Item(1), .End(xlDown)).Offset(0, -1).FillDown
End With

Case Is > 1
With ActiveCell(1, 0)
Range(.Item(1), .End(xlDown)).Offset(0, 1).FillDown
End With
End Select

Norie
10-12-2007, 11:23 AM
Do you really need to use FillDown?

What are you filling down? Data, formulas, series?

MachaMacha
10-12-2007, 01:19 PM
Not sure if this will help but I ususally use this


Sub Select_from_ActiveCell_to_Last_Cell_in_Column()
Dim topCel As Range
Dim bottomCel As Range
On Error GoTo errorHandler
Set topCel = ActiveCell
Set bottomCel = Cells((65536), topCel.Column).End(xlUp)
If bottomCel.Row >= topCel.Row Then
Range(topCel, bottomCel).Select
End If
Exit Sub
errorHandler:
MsgBox "Error no. " & Err & " - " & Error
End Sub