Before Save Macro

guarrac1no

New Member
Joined
Mar 26, 2009
Messages
7
In My sheet I would like to check to make sure col 15 is true before going through the process of adding the contents of each row from col 6 - 10 to column 5. (Col 5 could already contain values)

This is my code:

Code:
Private Sub Workbook_ThisWorkbook(ByVal SaveAsUI As Boolean, cancel As Boolean)
    BeginRow = 8
    EndRow = 87
    ChkCol = 15
    BeginCol = 6
    EndCol = 10

    For RowCnt = BeginRow To EndRow
        If Cells(RowCnt, ChkCol).Value = True Then
         For RowCnt = BeginRow To EndRow
            Cells(RowCnt, 5).Value = Cells(RowCnt, 5).Value + Cells(RowCnt, ColCnt).Value
            Next ColCnt
        End If
    Next RowCnt
End Sub


Any suggestions?
 
Last edited by a moderator:
Now I am getting Runtime Error '9'
subscript out of range

highlighted:
Set wksSheet5 = ThisWorkbook.Worksheets("Sheet5")

I copy and Pasted your code over mine in "ThisWorkbook"

I REALLY appreciate all this help
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Now I am getting Runtime Error '9'
subscript out of range

highlighted:
Set wksSheet5 = ThisWorkbook.Worksheets("Sheet5")

I copy and Pasted your code over mine in "ThisWorkbook"

I REALLY appreciate all this help

My guess would be that you changed the name of the sheet from "Sheet5" (on the tab) to some other name.

If that is not it, please click on the Go Advanced button and use the little pound sign button at the top of the msg window to tack in code tags. Then paste all the code from ThisWorkbook.

Mark
 
Upvote 0
Mark

You are right, I changed it to Tracking Master

I tried all of the following to no avail:

Set wksSheet5 = ThisWorkbook.Worksheets("Tracking Master")
Set wksSheet5 = ThisWorkbook.Worksheets("Sheet5(Tracking Master)")
Set wksSheet5 = ThisWorkbook.Worksheets("Sheet5")

Obviously the sheet name is Tracking Master

Mark
 
Upvote 0

Forum statistics

Threads
1,215,020
Messages
6,122,709
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top