VBA to unhide the row immediately after the last currently-visible row?

OTOTO

Board Regular
Joined
Dec 23, 2013
Messages
209
HI There! I would like to add to the following code! This is used so that double clicking in column Q will paste the content of that row into the "RiskRegister" worksheet's next available row. What I would like to happen in addition to this is for that row that the content is pasted to to become unhidden. The unhiding of the rows is done manually now and it is a complete pain. Any suggestions would be helpful

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim lMaxRows As Long
If Not Intersect(Target, Columns("Q")) Is Nothing Then
    Range(Cells(Target.row, "B"), Cells(Target.row, "M")).Copy
    With Sheets("RiskRegister")
        lMaxRows = .Cells(Rows.Count, "B").End(xlUp).row
        .Range("B" & lMaxRows + 1).PasteSpecial Paste:=xlPasteAll
        Application.CutCopyMode = False
    End With
End If
End Sub
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

BiocideJ

Well-known Member
Joined
Jan 23, 2012
Messages
1,733
If I understand your request correctly, the one red row should do the trick.

Rich (BB code):
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim lMaxRows As Long
If Not Intersect(Target, Columns("Q")) Is Nothing Then
    Range(Cells(Target.Row, "B"), Cells(Target.Row, "M")).Copy
    With Sheets("RiskRegister")
        lMaxRows = .Cells(Rows.Count, "B").End(xlUp).Row
        .Range("B" & lMaxRows + 1).PasteSpecial Paste:=xlPasteAll
        .Rows(lMaxRows + 1).Hidden = False
        Application.CutCopyMode = False
    End With
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,626
Messages
5,523,978
Members
409,549
Latest member
agus setiawan

This Week's Hot Topics

Top