VBA help

Emmily

Well-known Member
Joined
Oct 5, 2008
Messages
676
Hi, is there a macro that will produce the below result. For each team i want the count of entries per age criteria as reflected in row 1 and then i want the amount in (AUD) and then the number of entries which does not have a comment in col P and it value in AUD.

I know all of this can be done via formula, but i will have another 20 teams and the last age criteria will go to >90, so there will be a lot of formulas, hence it will slow the performance of the workbook.

Col L-P is raw data and R-S is FX data

Excel Workbook
ABCDEFGHIJKLMNOPQRS
12-56-29
2TeamNo.of itemsValue (AUD)No. of items without CommentsValue (AUD)No.of itemsValue (AUD)No. of items without CommentsValue (AUD)AmountCCYAgeSourceCommentsFX RATESRate (AUD)
3CMP1111,593.6615,796.8300.0000.008,268.57AUD1456TRACESAED3.712435
4TRACES20,000.00AUD1248TRACESANG1.809243
5LEHMAN1,000.00AUD1248TRACESARS4.053867
64,417.80GBP3CMP1TestATS10.203373
72,208.90GBP1018CMP1AUD1
8100,000.00AUD742TRACESBEF29.912398
91,163.22EUR561LEHMANBGN1.450275
10-3,320.14EUR561LEHMANGBP0.381053
119,646.51EUR561LEHMANTestBMD1.01075
12-12,618.80EUR561LEHMANBRL1.688256
13476,017.76EUR561LEHMANBSD1.01075
14-1,688,137.00JPY561LEHMANBVD2
157,187,517.00JPY561LEHMANCAD1.001098
16-6,303,971.00JPY561LEHMANCHF0.957838
17108,431.34USD561LEHMAN
18
19
20
Sheet1
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
age col will never be empty within the data, but i tried this and it worked. When you say empty do you mean empty rows up the header row?

lngAge = Trim$(ka(i, 9) + 0)
 
Upvote 0
Hi,

Try something like

Code:
If Len(Trim$(ka(i, 9))) = 0 Then
            MsgBox "Age is missing in '" & Sheets(SourceShtName).Range(SourceDataRange).Cells(i, 9).Address(0, 0) & "' on " & SourceShtName, vbInformation
            Exit Sub
        Else
            lngAge = Trim$(ka(i, 9))
        End If
 
Upvote 0
Awesome, this works. I did a test on full data and results look good. Thanks for your help on this.


Hi,

Try something like

Code:
If Len(Trim$(ka(i, 9))) = 0 Then
            MsgBox "Age is missing in '" & Sheets(SourceShtName).Range(SourceDataRange).Cells(i, 9).Address(0, 0) & "' on " & SourceShtName, vbInformation
            Exit Sub
        Else
            lngAge = Trim$(ka(i, 9))
        End If
 
Upvote 0
You are welcome !! :beerchug:

Kris, i noticed if a team is not in rng Source but its reflected in Sheet1 then the code removes this team from Sheet1. The teams in sheet1 must not be removed even if the team is not found in rngSource as there might not always be data available for those teams.
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

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