PDA

View Full Version : [SOLVED:] vba code if lastrow is full, it errors out



chubbychub
01-21-2023, 03:47 PM
i have userform with a vba code, the vba code its supposed to fill from inputbox 'boxestotal' into the next available empty cell within a range of cell on column d, but if cell D25 if full (first) then it detects it as entire D5 to D25 full, (altho there are empty cellss in between.
attached is a sample workbook. Please help, thanks in advance

PS. I used D25 to fill some data first sometimes.

arnelgp
01-21-2023, 10:34 PM
you test this one.

jolivanes
01-21-2023, 11:39 PM
In your code you have "GetLastCell"
That looks like a UDF but I can't find it.
Did you forget to copy/paste that?

SamT
01-22-2023, 04:13 AM
Next empty cell = Cells(5, "D").End(xlDown)

p45cal
01-22-2023, 05:48 AM
Instead of:

Set rng = GetLastCell(Range("D5:D26"), xlByRows)
try:

Set rng = Range("D5:D26").SpecialCells(xlCellTypeBlanks).Cells(1)or qualified a bit:

Set rng = Sheets("Sheet1").Range("D5:D26").SpecialCells(xlCellTypeBlanks).Cells(1)

chubbychub
01-22-2023, 02:46 PM
the post by arnelgp (http://www.vbaexpress.com/forum/member.php?74556-arnelgp) provided the solution and it works.