Hi guys,
I have a macro that prompts the sheet user to select the reports to 'load'. This opens up an external workbook, copies the data, then shuts the workbook down, and inserts command buttons onto the worksheet where the data was copied to.
Is it possible to assign a code to these command buttons that doesnt reside in the worksheet. i.e. can i have hte code in a module then assign to each of these newly created command buttons my macro all in the same operation?
the macro i wish to assign is below
![]()
Sub HideCrews() Dim i As Integer Dim j As String 'Dim k As Integer Dim Col As String Dim Sht As String Dim This Application.ScreenUpdating = False Col = Sheets("Data").Cells(8, 1).Value Sht = ActiveSheet.Name Sheets("Data").Visible = True Sheets("Data").Select Sheets("Data").Range(Col & "3").Select Selection.End(xlDown).Select j = ActiveCell.Row For i = 3 To j Sheets(Sht).Select If (Sheets("Data").Cells(i, Col).Offset(, 1).Value = "0") Then Sheets(Sht).Range(Sheets("Data").Range(Col & i)).EntireRow.Hidden = True End If Next i Application.ScreenUpdating = True End Sub
All this code does is references my control sheet "data" and hides Named Ranges![]()
Sub ShowCrews() Application.ScreenUpdating = False Cells.Select Selection.EntireRow.Hidden = False Range("K14").Select Application.ScreenUpdating = True End Sub
So i want my macro to assign a different macro to the command buttons that my macro creates.
thanks in advance
Bookmarks