Excel VBA / Windows 11

LordVoldetort_IV

New Member
Joined
Jun 10, 2021
Messages
38
Office Version
  1. 365
Platform
  1. Windows
Hello everyone!

So the below code works perfect in windows 10 and does what its supposed to, but i get errors when i try to run it in windows 11.

Any idea of what may be wrong and how to fix it?

Thanks!

VBA Code:
Private Sub DTPicker1_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)

End Sub

Private Sub Applychanges_Click()
With Worksheets("Tax Calculation")
   
'Last updated: 2021.04.09
'With function defines where to execute code
'BeginRow = from which row you want to start checking
'EndRow = to which row you want to check
'ChkCol = in which collom is the value to check
   
        BeginRow = 1
        EndRow = 400
        ChkCol = 19
   
        For RowCnt = BeginRow To EndRow
            If Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).value = "HIDE" Then
            Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).EntireRow.Hidden = True
            Else: Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).EntireRow.Hidden = False
            End If
        Next RowCnt
    End With
End Sub

Private Sub DTPicker2_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)

End Sub

Private Sub CommandButton1_Click()
Dim dateVariable As Date
dateVariable = CalendarForm.GetDate

Dim cellRange As Range
    Set cellRange = Range("K16")
    cellRange.value = dateVariable
End Sub

Private Sub email_button_Click()

    Dim OutApp As Object
    Dim OutMail As Object
   
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
        .To = "xx@xx.co.za"
        .Subject = "Individual's Tax Calc: errors and suggestions"
        .Body = "<please describe the issue or suggestion here>"
        .Attachments.Add ActiveWorkbook.FullName
        .Display
    End With
    On Error GoTo 0

End Sub

Private Sub FinalizeTC_Click()
With Worksheets("Tax Calculation")
   
'Last updated: 2021.04.09
'With function defines where to execute code
'BeginRow = from which row you want to start checking
'EndRow = to which row you want to check
'ChkCol = in which collom is the value to check
   
        BeginRow = 1
        EndRow = 400
        ChkCol = 20
   
        For RowCnt = BeginRow To EndRow
            If Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).value = "HIDE" Then
            Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).EntireRow.Hidden = True
            End If
        Next RowCnt
    End With
End Sub

Private Sub UnhideAll_Click()
With Worksheets("Tax Calculation")
   
'Last updated: 2021.04.09
'With function defines where to execute code
'BeginRow = from which row you want to start checking
'EndRow = to which row you want to check
'ChkCol = in which collom is the value to check
   
        BeginRow = 1
        EndRow = 400
        ChkCol = 19
   
        For RowCnt = BeginRow To EndRow
            If Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).value = "HIDE" Or Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).value = "SHOW" Then
            Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).EntireRow.Hidden = False
            End If
        Next RowCnt
    End With
End Sub

Sub Worksheet_Change(ByVal Target As Range)

'this is for the investment income section
   
    If Target.Address = "$D$36" Then
        With Worksheets("Info Sheet")
   
'Last updated: 2021.04.09
'With function defines where to execute code
'BeginRow = from which row you want to start checking
'EndRow = to which row you want to check
'ChkCol = in which collom is the value to check
   
        BeginRow = 1
        EndRow = 110
        ChkCol = 20
   
        For RowCnt = BeginRow To EndRow
            If Worksheets("Info Sheet").Cells(RowCnt, ChkCol).value = "HIDE" Then
            Worksheets("Info Sheet").Cells(RowCnt, ChkCol).EntireRow.Hidden = True
            Else: Worksheets("Info Sheet").Cells(RowCnt, ChkCol).EntireRow.Hidden = False
            End If
        Next RowCnt
    End With
    End If
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Which errors do you get precisely? And on which lines of the code?
NB: Your use of the With...End With statements is wrong:
This:
VBA Code:
Private Sub Applychanges_Click()
    With Worksheets("Tax Calculation")

        'Last updated: 2021.04.09
        'With function defines where to execute code
        'BeginRow = from which row you want to start checking
        'EndRow = to which row you want to check
        'ChkCol = in which collom is the value to check

        BeginRow = 1
        EndRow = 400
        ChkCol = 19

        For RowCnt = BeginRow To EndRow
            If Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).Value = "HIDE" Then
                Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).EntireRow.Hidden = True
            Else: Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).EntireRow.Hidden = False
            End If
        Next RowCnt
    End With
End Sub
should be replaced with this:
Code:
Private Sub Applychanges_Click()
    With Worksheets("Tax Calculation")

        'Last updated: 2021.04.09
        'With function defines where to execute code
        'BeginRow = from which row you want to start checking
        'EndRow = to which row you want to check
        'ChkCol = in which collom is the value to check

        BeginRow = 1
        EndRow = 400
        ChkCol = 19

        For RowCnt = BeginRow To EndRow
            If .Cells(RowCnt, ChkCol).Value = "HIDE" Then
                .Cells(RowCnt, ChkCol).EntireRow.Hidden = True
            Else: .Cells(RowCnt, ChkCol).EntireRow.Hidden = False
            End If
        Next RowCnt
    End With
End Sub
 
Upvote 0
Which errors do you get precisely? And on which lines of the code?
NB: Your use of the With...End With statements is wrong:
This:
VBA Code:
Private Sub Applychanges_Click()
    With Worksheets("Tax Calculation")

        'Last updated: 2021.04.09
        'With function defines where to execute code
        'BeginRow = from which row you want to start checking
        'EndRow = to which row you want to check
        'ChkCol = in which collom is the value to check

        BeginRow = 1
        EndRow = 400
        ChkCol = 19

        For RowCnt = BeginRow To EndRow
            If Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).Value = "HIDE" Then
                Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).EntireRow.Hidden = True
            Else: Worksheets("Tax Calculation").Cells(RowCnt, ChkCol).EntireRow.Hidden = False
            End If
        Next RowCnt
    End With
End Sub
should be replaced with this:
Code:
Private Sub Applychanges_Click()
    With Worksheets("Tax Calculation")

        'Last updated: 2021.04.09
        'With function defines where to execute code
        'BeginRow = from which row you want to start checking
        'EndRow = to which row you want to check
        'ChkCol = in which collom is the value to check

        BeginRow = 1
        EndRow = 400
        ChkCol = 19

        For RowCnt = BeginRow To EndRow
            If .Cells(RowCnt, ChkCol).Value = "HIDE" Then
                .Cells(RowCnt, ChkCol).EntireRow.Hidden = True
            Else: .Cells(RowCnt, ChkCol).EntireRow.Hidden = False
            End If
        Next RowCnt
    End With
End Sub
Thanks for the help on the with statements!

The error i get is "Compile Error: Cant find project or library" and that it highlights the "Private Sub Applychanges_Click()" section
 
Upvote 0
It must have been installed by either an older version of office, or by other software. Which office version do you have?
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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