Go to next available cell

  • Thread starter Thread starter Anne
  • Start date Start date
A

Anne

I need to place a value in the next available cell. This
is the code I am trying to use, but I get a 1004 run-time
error.

Range("A6").Select
Range(Selection, Selection.End(x1down).Offset(1, 0)).Select
 
Hi
try
activesheet.Cells(Rows.count, "A").End(xlUp).offset(1,0).select
 
I replaced my code with yours and still get the 1004 error
on the new line of code. Here's all the code for my macro,
if that helps. I am trying to enter a description on the
first sheet, which then puts that description in column B
on the next available line in the second sheet and assigns
the next number in column A and then displays that next
number back on the first sheet.

Range("B6").Select
ActiveCell.FormulaR1C1 = "=1+'Assigned Drawing
Numbers'!R[8]C[-1]"
Range("B6").Select
Selection.Copy
Sheets("Assigned Drawing Numbers").Select
ActiveSheet.Cells(Rows.Count, "A").End(x1down).Offset
(1, 0).Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("B15").Select
Sheets("New Drawing").Select
Application.CutCopyMode = False
Range("B4").Select
Selection.Cut
Sheets("Assigned Drawing Numbers").Select
ActiveSheet.Paste
Sheets("New Drawing").Select
Range("B4").Select
 
Hi,

Trying your code I also got the 1004 error but having replaced a coupl
of your lines with the code below (admittedly taken from another pos
on finding the last occupied cell) I found that it worked.

Replace

ActiveSheet.Range(Rows.Count, "A").End(x1down).Offset(1, 0).Select

With

Number_of_rows = WorksheetFunction.CountA(Range("A1:A" & Rows.Count))
Cells(Number_of_rows, 1).Offset(1, 0).Select


Having said that you MUST have some data in Cell A1 of "Assigne
Drawing Numbers" otherwise Excel goes all the way down to row 65536 an
then cannot offset by one more row.

Regards

Seamu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top