LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default VBA problems

I've been trying to create a macro that will do the following: I want
the macro to loop through a bunch of funds and calculate what would
happen if we allocated 5% to the fund. I have about 20 funds I want to
loop through, all start out with a weight of zero. I then chnage the 0%
to 5% for one fund at a time and copy the resulting volatility
(calcualted iwth the new weight) onto a separate spreadsheet called
Summary. C4 links to the new volatility on the AG spreadsheet, but
needs to be copied,pasted each time since the link stays the same but
the value obviuolsy changes as the weight is updated (im also doing
this with returns and betas/correlations, hence the "G4", "O4" and
"S4"). im encountering a few problems--the macro is giving me problems
with the 2 separately named spreadsheets (I get the error Select method
of range class failed). Then I was also havign a problem with the paste
special function. any suggestions? Is this set up completely wrong???

Worksheets("AG").Range("A76").Select
For i = 0 To 20
Do Until i = 20
ActiveCell.Offset(0 + i, 3).Select
ActiveCell.FormulaR1C1 = "5%"
Worksheets("Summary").Range("C4").Select
Selection.Copy
ActiveCell(0 + i, 1).Range("C4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Worksheets("Summary").Range("G4").Select
Selection.Copy
ActiveCell(0 + i, 1).Range("G4").Select
Selection.PasteSpecial Paste:=xlPasteValues
Worksheets("Summary").Range("O4").Select
Selection.Copy
ActiveCell(0 + i, 1).Range("o4").Select
Selection.PasteSpecial Paste:=xlPasteValue
Worksheets("Summary").Range("S4").Select
Selection.Copy
ActiveCell(0 + i, 1).Range("S4").Select
Selection.PasteSpecial Paste:=xlPasteValue
Worksheets("AG").Range("A76").Select
ActiveCell.Offset(0 + i, 3).Select
ActiveCell.FormulaR1C1 = "0%"
Loop
Next i
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
aauugghhh...#div/o problems & various average formula problems acbel40 Excel Worksheet Functions 5 October 19th 09 05:00 PM
Problems with sum + if Darren Excel Programming 3 March 23rd 06 08:11 AM
Problems merging an excel file due to code or file problems? Cindy M -WordMVP- Excel Programming 0 September 14th 04 02:58 PM
can someone help me with this problems please? DEBBZ : Excel Programming 2 July 3rd 04 12:42 AM
VBA Problems Chris Excel Programming 1 August 13th 03 01:30 AM


All times are GMT +1. The time now is 06:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"