Yeoman.jeremy
Board Regular
- Joined
- Apr 4, 2011
- Messages
- 90
Hi there.
I need to include in one of my macros coding that disables certain macros, and enables others.
I have in my sheet checkboxes, that when ticked adjusts values on a different workbook, and when unchecked it reverts the values to how they were.
The problem with this is that my "clear all" macro unchecks these, which in turn reverts the values on the other workbook to how they were.
I tried to fix this by including in the "clear all" macro a bit of messy coding to add to the values on the other book to balance it out. so at the moment it does this.
(on check) adds one to a cell on the other workbook
(on "clear all")unchecks, therefore removing one from that cell on the other workbook
if checkbox_35 was checked, adds one to the cell again.
This DOES fix the problem, but it means that there is a whole load of screen flicking as it switches between workbooks.
Here is my code
I need to include in one of my macros coding that disables certain macros, and enables others.
I have in my sheet checkboxes, that when ticked adjusts values on a different workbook, and when unchecked it reverts the values to how they were.
The problem with this is that my "clear all" macro unchecks these, which in turn reverts the values on the other workbook to how they were.
I tried to fix this by including in the "clear all" macro a bit of messy coding to add to the values on the other book to balance it out. so at the moment it does this.
(on check) adds one to a cell on the other workbook
(on "clear all")unchecks, therefore removing one from that cell on the other workbook
if checkbox_35 was checked, adds one to the cell again.
This DOES fix the problem, but it means that there is a whole load of screen flicking as it switches between workbooks.
Here is my code
Code:
Sub NewJobSheet_mcr()
Dim wbJobSheet As Workbook
Dim wbStats As Workbook
Dim strTestFileName As String
Dim srtPath As String
Set wbJobSheet = ThisWorkbook ' create reference to the workbook the code is in
strPath = "C:\Users\owner\Desktop\Presentation Job Sheet\"
strTestFileName = "Quoting Statistics"
' open and create a reference to the 'Test Over WBk' workbook
On Error Resume Next
If Sheets("Job Sheet").CheckBox35 = True Then
Set wbStats = Workbooks.Open(strPath & strTestFileName)
With wbStats.Sheets("Sheet1")
.range("D5").Value = .range("D5") + 1
End With
End If
If wbJobSheet.Sheets("Job Sheet").CheckBox38 = True Then
With wbStats.Sheets("Sheet1")
.range("f5").Value = .range("f5") + 1
End With
End If
With wbStats.Sheets("Sheet1")
.range("E5").Value = .range("E5") + 1
wbStats.Close (True)
End With
Call ClearForm_mcr
Call Uncheck
Call AlterDuplicate_mcr
ThisFile = range("J6").Value
ChDir "C:\Users\owner\Desktop\Development\Quotes to sort"
ActiveWorkbook.SaveAs FileName:=ThisFile
Call ReturnDuplicate_mcr
Call ClearForm_mcr
Call Uncheck
[g2] = [g2] + 1
End Sub