ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Envoke code with button rather than as data is entered. (https://www.excelbanter.com/excel-programming/378368-envoke-code-button-rather-than-data-entered.html)

JOUIOUI

Envoke code with button rather than as data is entered.
 
I'm using this code to populate the WS "Summary" if any of the other
worksheets in the WB have data in Col A and B. As col A and B have text
entered into them, it also goes to the Summary WS in Col A and B respectively
with the source WS name in Col C. I would like to alter this code to have
it launch with a button rather than when data is entered into the worksheets.
Any suggestions on how to do this? Also I need the summary WS to populate
in columns B, C and D instead of A, B and C since I now have the row numbers
in col A. Thanks again.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Target.Column = 2 Then
Application.Screenupdating = False
With Sheets("Summary")
Target.Offset(, -1).Resize(, 2).Copy
..Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
..Range("C" & Rows.Count).End(xlUp).Offset(1).Value = Me.Name
End With
Application.Screenupdating = True
End If

End Sub



All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com