• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Why when line gets inserted does it then get hidden

Cammandk

Member
I have the code below to insert lines on a sheet.
It works correctly and inserts the lines BUT then the lines get hidden.
I can't understand what is causing this. There is no event code in the worksheet module.

DK.


Sub InsertSch1NotesLine()
Dim myRow As Long
Application.ScreenUpdating = False
'Application.Calculation = xlCalculationManual
myRow = ActiveCell.Row
If Cells(myRow, "E").Value <> 1 Then
MsgBox "Can't insert an Notes Line here", vbOKOnly, "Invalid Line"
Exit Sub
Else
myInput = InputBox("How many lines do you want to insert?", "# of Lines", 1)
'Rows("95:100").EntireRow.Hidden = False
Range("InsertSch1NotesLine").EntireRow.Copy
myInput = myInput * Range("InsertSch1NotesLine").Rows.Count
ActiveCell.Resize(myInput, 1).EntireRow.Insert
'Rows("95:100").EntireRow.Hidden = True
 
In your actual workbook, are those commented lines still there?
Do you have any purposely hidden rows on sheet?
Are you using freeze panes by chance?
 
Hi Luke
Not sure what you mean by your first line.
I do have 1 row that is hidden which is the line that gets copied to be inserted - its within the area of Row 95:100
I am freezing panes at row 8.

DK
 
In the code you posted, some of the lines are commented out (shown in green)
Code:
Sub InsertSch1NotesLine()
Dim myRow As Long
Application.ScreenUpdating = False
'Application.Calculation = xlCalculationManual
myRow = ActiveCell.Row
If Cells(myRow, "E").Value <> 1 Then
MsgBox "Can't insert an Notes Line here", vbOKOnly, "Invalid Line"
Exit Sub
Else
myInput = InputBox("How many lines do you want to insert?", "# of Lines", 1)
'Rows("95:100").EntireRow.Hidden = False
Range("InsertSch1NotesLine").EntireRow.Copy
myInput = myInput * Range("InsertSch1NotesLine").Rows.Count
ActiveCell.Resize(myInput, 1).EntireRow.Insert
'Rows("95:100").EntireRow.Hidden = True
End Sub
I was wondering if that how it really is in your actual workbook?
 
Back
Top