Insert copied cells above hidden Named Range

M

Munchkin

I'm not sure what happened here - this worked in the past, but suddenly there
is a problem with "Selection.Insert Shift:=xlDown".

The "record end" named range is still there, so it's not that. The marco is
supposed to go to "RecordEnd" which is hidden, unhide it, insert the copied
cells while pushing "RecordEnd" below the inserted cells. It worked before -
anybody know what I'm doing wrong?

Sheets("DRIVER LIST").Select
Application.Goto Reference:="RecordEnd"
Selection.EntireRow.Hidden = True
Selection.Insert Shift:=xlDown
Application.Goto Reference:="RecordEnd"
Selection.EntireRow.Hidden = True
ActiveCell.Offset(-1).Activate
 
D

Don Guillett

Try this. Tested from another sheet where f6 was copied to the the cell
above the hiddencell. NO selections.

Sub copybeforehiddenrow()
Range("f6").Copy
Range("hiddencell").Insert shift:=xlDown
End Sub
 
F

FSt1

hi
the code you posted doesn't unhide the hidden range. it hides in again.
which is what i think is wrong. change the first
Selection.EntireRow.Hidden = True
to false ie
Selection.EntireRow.Hidden = False

then it should start doing what you expect.
i think.

regards
FSt1
 
O

OssieMac

You are hiding an entire row and only shifting one cell down. Is this what
you intended?

You are also hiding the row with reference RecordEnd twice.

Sheets("DRIVER LIST").Select
Application.Goto Reference:="RecordEnd"
Selection.EntireRow.Hidden = True
'Selection.Insert Shift:=xlDown 'Only shifts 1 cell down

'*****************************************
Selection.EntireRow.Insert Shift:=xlDown 'Shifts entire row
'*****************************************
Application.Goto Reference:="RecordEnd"
'Selection.EntireRow.Hidden = True 'Superfluous
ActiveCell.Offset(-1).Activate

Just for information there is no need to actually select the ranges. The
above code (as written above for entire row shifted) could be written as
follows.

Sheets("DRIVER LIST").Select
Range("RecordEnd").EntireRow.Hidden = True
Range("RecordEnd").EntireRow.Insert Shift:=xlDown
Range("RecordEnd").Offset(-1).Activate
 

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

Top