Adding a Max To Sum Formula - VBA

Mark_Annonyous

New Member
Joined
May 9, 2020
Messages
20
Office Version
  1. 365
Platform
  1. Windows
HI,

I hope everyone i staying clear of the storms that are hammering the U.S. ( for those of you who live there)

As the title suggests, i am looking for a push in the right direction to convert the below code into to something more binary. Rather than summing the result, i want a 1 or 0.

I've tried putting a application.max function but it just errors out.

VBA Code:
For ColumnCounter = 5 To 1099
        Exportdate = alldata(1, ColumnCounter)
    For RowCounter = 2 To LastRowSummary
        ExShipCount = 0
        VesselName = alldata(RowCounter, 1) 'For each cell being evaluated, we need to store the Export country in column 1 to be evaluated.
       
        For DataImportCounter = 1 To LastRowDataImport
            If Reutdata(DataImportCounter, 29) = 1 Then
                If Reutdata(DataImportCounter, 1) = VesselName Then
                    If Exportdate >= Reutdata(DataImportCounter, 31) And Exportdate <= Reutdata(DataImportCounter, 32) Then
                      
                       ExShipCount = ExShipCount + 1

                    End If
                  End If
                End If
            
        Next DataImportCounter

         output1(RowCounter - 1, ColumnCounter - 4) = ExShipCount

    Next RowCounter
Next ColumnCounter

  Range(.Cells(2, 5), .Cells(LastRowSummary, 1099)) = output1
 
Last edited by a moderator:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I don't know if your question is quite clear without seeing what your data looks like.
You also appear to be using some UDFs for which you have NOT posted the VBA code (Reutdata and alldata).

I would recommend posting an example of the data you are working with along with your desired result so we can clearly see what you are working with and what you are trying to accomplish.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
At a guess, you mean something like:

Code:
output1(RowCounter - 1, ColumnCounter - 4) = IIf(ExShipCount > 0, 1, 0)
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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