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
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,592
Messages
5,832,630
Members
430,149
Latest member
amitk1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top