I been trying to figuer this out but I can't. My question is how to assing your macros to the options buttons? The options buttons are from the Forms. See I have a macro that format the sheet also it imports the module from C:\Drive This module are the macros for the options buttons.
The module name is Inventory.bas Here are the macros that are stored in the module.
Sub Sort_Wip()
'
' Sort_Wip Macro
' Macro recorded 8/6/2004 by EDI1
'
'
Columns("A:E").Select
Range("E1").Activate
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("F1").Select
End Sub
Sub Sort_Fgs()
'
' Sort_Fgs Macro
' Macro recorded 8/6/2004 by EDI1
'
'
Columns("A:E").Select
Range("E1").Activate
Selection.Sort Key1:=Range("E2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("F1").Select
End Sub
Sub Highlight_Negatives()
'
' Highlight_Negatives Macro
' Macro recorded 8/6/2004 by EDI1
'
'
Columns("D:E").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(1).Interior.ColorIndex = 3
Range("F1").Select
End Sub
Sub Add_Negatives()
'
' Add_Negatives Macro
' Macro recorded 8/6/2004 by EDI1
'
'
Range("F4").Select
ActiveCell.FormulaR1C1 = "=SUMIF(R[-2]C[-2]:R[1126]C[-2],""<0"")"
Range("G4").Select
ActiveCell.FormulaR1C1 = "=SUMIF(R[-2]C[-2]:R[1026]C[-2],""<0"")"
Range("F4:G4").Select
Range("G4").Activate
Selection.Font.Bold = True
Range("F1").Select
End Sub
Display More
I tried to do a simple macro recored to assign the macros from the imported module to the Options Buttons but it does not work. The link below is the first time I needed help how to do this automatically. He suggested to do the control box instead It works fine But I would have to assign the macros manually! Now how can I do this without doing it manually. Can we do this automatic?
http://www.ozgrid.com/forum/showthread.php?t=32108
I have one workbook that the macros are not assign
and another is assign.
This code below is how I import my module to the workbook.
Dim wbFileName As Variant
Dim FS As Office.FileSearch
Dim vaFileName As Variant
wbFileName = Application.GetOpenFilename("XLS Files (*.xls), *.xls")
If wbFileName <> False Then
Workbooks.Open Filename:=wbFileName
Set FS = Application.FileSearch
With FS
'clear old search criteria
.NewSearch
'directory to search
.LookIn = "C:"
'look for .bas (Module) files
.Filename = "Inventory.bas"
'carry out search
.Execute
For Each vaFileName In .FoundFiles
'MsgBox "About to import module " & vaFileName
ActiveWorkbook.VBProject.VBComponents.Import Filename:=vaFileName
Next vaFileName
End With
Display More