VBA help

Isabella

Well-known Member
Joined
Nov 7, 2008
Messages
643
Hi All, i have a work task which i perform every month which i need automating. I have 3 worksheets at present (RawData, SMPJPD15, SMPUB915). From the raw data i will copy data for each unique security (Col B) to its own worksheet and then insert row between each unique portfolio. See below examples:

Ranges are correct as shown in the examples.

Excel Workbook
ABCDEFGHIJK
4PfCodeSecurity Short NameReportGroupCategory&SubtypeIDNumberTransShortNameBrokerCodeContractDateSettlementDate TransUnits
5RSTAHYSMPJPD15SMP JP 061215 CC 85DS04157957DS-PURJPMAUD22/12/201022/12/2010-3,500,000.00
6RSTAHYSMPJPD15SMP JP 061215 CC 85DS04158305DS-PURJPMAUD23/12/201023/12/2010-440,000.00
7RSTBFASMPJPD15SMP JP 061215 CC 85DS04157959DS-PURJPMAUD22/12/201022/12/2010-3,150,000.00
8RSTBFASMPJPD15SMP JP 061215 CC 85DS04158304DS-PURJPMAUD23/12/201023/12/2010-480,000.00
9RTFDBGSMPJPD15SMP JP 061215 CC 85DS04157958DS-PURJPMAUD22/12/201022/12/2010-770,000.00
10RTFDBGSMPJPD15SMP JP 061215 CC 85DS04160168DS-PURJPMSYD30/12/201030/12/2010-280,000.00
11RTFDBGSMPJPD15SMP JP 061215 CC 85DS04160457INT INT 31/12/201031/12/20100.00
12RTEYFGSMPUB915SMP UBS 092015 CC 85DS04150708DS-PURUBSAUD3/12/20103/12/2010-380,000.00
13RTEYFGSMPUB915SMP UBS 092015 CC 85DS04151121DS-PURUBSAUD6/12/20106/12/2010-440,000.00
14RTEYFGSMPUB915SMP UBS 092015 CC 85DS04152649DS-PURUBSAUD8/12/20108/12/2010-520,000.00
15RTFDBGSMPUB915SMP UBS 092015 CC 85DS04154816DS-PURUBSAUD14/12/201014/12/2010-260,000.00
16RTFDBGSMPUB915SMP UBS 092015 CC 85DS04155882DS-PURUBSAUD16/12/201016/12/2010-570,000.00
17RTFDBGSMPUB915SMP UBS 092015 CC 85DS04158291DS-PURUBSAUD23/12/201023/12/2010-490,000.00
18RTFDBGSMPUB915SMP UBS 092015 CC 85DS04159263DS-PURUBSAUD29/12/201029/12/2010-520,000.00
19RSTBFASMPUB915SMP UBS 092015 CC 85DS04160460INT INT 31/12/201031/12/20100.00
20RSTBFASMPUB915SMP UBS 092015 CC 85DS04160656DS-PURUBSAUD31/12/201031/12/2010-320,000.00
RawData



Excel Workbook
ABCDEFGHI
5PfCodeSecurityShort NameIDNumberTransShortNameBrokerCodeContract DateSettlementDateTrans Units
6RSTAHYSMPJPD15SMP JP 061215 CC 157957DS-PURJPMAUD22/12/201022/12/2010-3,500,000.00
7RSTAHYSMPJPD15SMP JP 061215 CC 158305DS-PURJPMAUD23/12/201023/12/2010-440,000.00
8
9RSTBFASMPJPD15SMP JP 061215 CC 157959DS-PURJPMAUD22/12/201022/12/2010-3,150,000.00
10RSTBFASMPJPD15SMP JP 061215 CC 158304DS-PURJPMAUD23/12/201023/12/2010-480,000.00
11
12RTFDBGSMPJPD15SMP JP 061215 CC 157958DS-PURJPMAUD22/12/201022/12/2010-770,000.00
13RTFDBGSMPJPD15SMP JP 061215 CC 160168DS-PURJPMSYD30/12/201030/12/2010-280,000.00
14RTFDBGSMPJPD15SMP JP 061215 CC 160457INT INT 31/12/201031/12/20100.00
15
16
SMPJPD15


Excel Workbook
ABCDEFGHI
5PfCodeSecurityShort NameIDNumberTransShortNameBrokerCodeContract DateSettlementDateTrans Units
6RTEYFGSMPUB915SMP UBS 092015 CC 150708DS-PURUBSAUD3/12/20103/12/2010-380,000.00
7RTEYFGSMPUB915SMP UBS 092015 CC 151121DS-PURUBSAUD6/12/20106/12/2010-440,000.00
8RTEYFGSMPUB915SMP UBS 092015 CC 152649DS-PURUBSAUD8/12/20108/12/2010-520,000.00
9
10RTFDBGSMPUB915SMP UBS 092015 CC 154816DS-PURUBSAUD14/12/201014/12/2010-260,000.00
11RTFDBGSMPUB915SMP UBS 092015 CC 155882DS-PURUBSAUD16/12/201016/12/2010-570,000.00
12RTFDBGSMPUB915SMP UBS 092015 CC 158291DS-PURUBSAUD23/12/201023/12/2010-490,000.00
13RTFDBGSMPUB915SMP UBS 092015 CC 159263DS-PURUBSAUD29/12/201029/12/2010-520,000.00
14
15RSTBFASMPUB915SMP UBS 092015 CC 160460INT INT 31/12/201031/12/20100.00
16RSTBFASMPUB915SMP UBS 092015 CC 160656DS-PURUBSAUD31/12/201031/12/2010-320,000.00
17
18
19
SMPUB915
 
Isabella,

I can not see the .Borders.Weight = xlHairline formatting in your last post.

And, it looks like you have changed where the formulae go.


Please attach a workbook with the three worksheets, RawData, SMPJPD15, and SMPUB915, completed the way you want to see it.

You can upload your workbook to www.box.net and provide us with a link to your workbook.
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hiker i worked it out myself on what i need to do, i add the below to the code and it works fine.

Thanks for your help on this.


Code:
With Worksheets(WSary(a)).Range("A6:M" & NR & ",Q6:R" & NR)
        .Borders.LineStyle = xlNone
        .Borders.LineStyle = xlContinuous
        .Interior.ColorIndex = 0
        .Borders.Weight = xlHairline
       End With
        With Worksheets(WSary(a)).Range("N6:P" & NR & ",S6:S" & NR)
            .Borders.LineStyle = xlContinuous
            .Borders.Weight = xlThin
            .Interior.ColorIndex = 24
            .Borders.ColorIndex = 2
        End With
Isabella,

I can not see the .Borders.Weight = xlHairline formatting in your last post.

And, it looks like you have changed where the formulae go.


Please attach a workbook with the three worksheets, RawData, SMPJPD15, and SMPUB915, completed the way you want to see it.

You can upload your workbook to www.box.net and provide us with a link to your workbook.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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