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 code not working- repost to further explain problem

My macro shoudl work as follows: i have 2 sheets, AG and Summary. On
the AG sheet, I have 20 short list funds (starting in cell A76) that I
want to add in to the current portfolio at a 5% weighting (which is in
column D), and then I calculate the new volatility, return, beta to teh
S&P and correlation to the S&P. The Summary sheet links to the AG sheet
and to the specific cells that contain these new results, so for
example C4 on Summary links to the new volatility of the portfolio with
the short list fund, G4 links to the new return, O4 links to the new
beta and S4 links to the new correl. Now I want to take these numbers
(say C4) and copy paste special the value to D4. Then it shd go back,
make the % of the first short list fund equla to 0% and the second fund
should now be equal to 5%. THe links are still the same so now I want
to copy, pastespecial C4 to D5, and so on. The code below does not loop
through (stays on AG.D76, when it shd go to AG.D77 and so on). It also
goes to cell C3 in the summary worksheet instaed of C4 and doesnt seem
to be doing any pasting. Is this code completely wrong? ANy
suggestions?


Dim i As Integer
For i = 0 To 20
Do Until i = 20
Application.GoTo Sheets("AG").Range("A76") 'this needs to reflect where
list starts
ActiveCell.Offset(0 + i, 3).Select 'weighting starts in column D76,
then goes to D77, etc
ActiveCell.FormulaR1C1 = "5%" 'changes weight from 0 to 5%
Application.GoTo Sheets("Summary").Range("C4")
Selection.Copy 'copy volatility to adjacent cell
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Application.GoTo Sheets("Summary").Range("G4") 'copy return
Selection.Copy
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.GoTo Sheets("Summary").Range("O4") 'copy beta
Selection.Copy
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.GoTo Sheets("Summary").Range("S4") 'copy correlation
Selection.Copy
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.GoTo Sheets("AG").Range("A76")
ActiveCell.Offset(0 + i, 3).Select
ActiveCell.FormulaR1C1 = "0%" 'change D76 back to 0%
Loop ' go to D77 and repeat actions up until D95
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
Please Explain Two Lines of Code ca1358 Excel Programming 1 January 18th 06 04:47 PM
Sorry, this is a repost, cuz i didn't explain myself right nydia Excel Discussion (Misc queries) 3 February 1st 05 08:32 PM
Can someone explain this code to me dht[_2_] Excel Programming 1 September 13th 04 12:03 PM
Pastespecial via vbscript not working - REPOST news.easynews.com Excel Programming 1 December 21st 03 03:24 PM
Please explain why following code doesn't work.... FMNT80 Excel Programming 2 July 23rd 03 06:07 PM


All times are GMT +1. The time now is 09:47 PM.

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"