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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,141
Members
449,066
Latest member
Andyg666

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
Back
Top