I have a Workbook with three WorkSheets: Product , Customer, Journal. What I need is a macro assigned to a button within each one of the above Sheets. If the button is click
The first one is simple. Use Application.GetSaveAsFilename to allow the user to nominate a path and filename.
I've used the following from Chip Pearson to strip the VBA out of a copied workbook before, it should do what you are after:
Sub DeleteAllVBACode()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Set VBProj = myWorkbook.VBProject
For Each VBComp In VBProj.VBComponents
If VBComp.Type = vbext_ct_Document Then
Set CodeMod = VBComp.CodeModule
With CodeMod
.DeleteLines 1, .CountOfLines
End With
Else
VBProj.VBComponents.Remove VBComp
End If
Next VBComp
End Sub
Sorry, not got time to review your code in detail (leaving work!)