Determine if integer

foxhound

Board Regular
Joined
Mar 21, 2003
Messages
182
Hello. I may be completely off base with this but I am using the following code in Access and need help. How can I modify the following to check if the count of "i" is divisible by 10...if it is then save the Excel workbook I have open and if it isn't divisible by 10 then do nothing? So, basically, I am looking to see if the total count of worksheets divided by 10 is a whole number. If so, then save the workbook and continue through the loop.

Code:
        xlApp.DisplayAlerts = False
        With xlWb
            Dim i As Integer
            i = .Sheets.Count
                If isinteger(i / 10) Then
                    ActiveWorkbook.Save
                Else 'continue
                End If
            For y = 1 To i
            xlWb.Sheets(y).Select
                With ActiveSheet
                If Left(xlWb.Sheets(y).NAME, 5) = "Sheet" Then
                    xlWb.Sheets(y).Delete
                GoTo recount
                End If
                End With
            Next y
        End With
        xlApp.DisplayAlerts = True
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
foxhound said:
Hello. I may be completely off base with this but I am using the following code in Access and need help. How can I modify the following to check if the count of "i" is divisible by 10...if it is then save the Excel workbook I have open and if it isn't divisible by 10 then do nothing? So, basically, I am looking to see if the total count of worksheets divided by 10 is a whole number. If so, then save the workbook and continue through the loop.

Code:
        xlApp.DisplayAlerts = False
        With xlWb
            Dim i As Integer
            i = .Sheets.Count
                If i mod 10 =0 Then
                    ActiveWorkbook.Save
                Else 'continue
                End If
            For y = 1 To i
            xlWb.Sheets(y).Select
                With ActiveSheet
                If Left(xlWb.Sheets(y).NAME, 5) = "Sheet" Then
                    xlWb.Sheets(y).Delete
                GoTo recount
                End If
                End With
            Next y
        End With
        xlApp.DisplayAlerts = True
The mod function returns the remainder of a divisi
 
Upvote 0
foxhound said:
Hello. I may be completely off base with this but I am using the following code in Access and need help. How can I modify the following to check if the count of "i" is divisible by 10...if it is then save the Excel workbook I have open and if it isn't divisible by 10 then do nothing? So, basically, I am looking to see if the total count of worksheets divided by 10 is a whole number. If so, then save the workbook and continue through the loop.

Code:
        xlApp.DisplayAlerts = False
        With xlWb
            Dim i As Integer
            i = .Sheets.Count
                If i mod 10 =0 Then
                    ActiveWorkbook.Save
                Else 'continue
                End If
            For y = 1 To i
            xlWb.Sheets(y).Select
                With ActiveSheet
                If Left(xlWb.Sheets(y).NAME, 5) = "Sheet" Then
                    xlWb.Sheets(y).Delete
                GoTo recount
                End If
                End With
            Next y
        End With
        xlApp.DisplayAlerts = True
The mod function returns the remainder of a division
 
Upvote 0

Forum statistics

Threads
1,221,657
Messages
6,161,084
Members
451,684
Latest member
smllchng5

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