Hello,
I have built a model where I have various inputs and various outputs. I have managed to set up the model so that whenever i hit the 'add to portfolio' button, a new row is added putting in the details from the inputs to a new row (beginning in row 25). The problem I am having is that I cannot seem to get the output results (cells I12:I17) to be included as well. I have attached my excel file. If anyone could take a look at this, I would greatly appreciate it.
Thanks so much,
Ayesha
Last edited by ayesha; 10-09-2009 at 03:46 PM.
Your are missing this code
For k = 1 To Range("range_results_details").Rows.Count - 1 Range("anchor_position_table").Offset(1, 7 + k).Value = Range("range_results_details").Cells(k, 1).Value Next k
Shijesh Kumar
http://shijesh.wordpress.com/
Thanks Shijesh,
Is this the correct code?
It works except that it leaves cells N25 empty (which is the output result from I17). Could you please advise?Sub Add_Position() Dim i As Integer ' loop variable Dim k As Integer ' insert a new row into the table Range("anchor_position_table").Offset(1, 0).EntireRow.Select Selection.Copy Selection.Insert Shift:=xlDown Application.CutCopyMode = False Range("anchor_position_table").Select ' copy option details into the new row For i = 1 To Range("range_option_details").Rows.Count Range("anchor_position_table").Offset(1, i - 1).Value = Range("range_option_details").Cells(i, 1).Value Next i For k = 1 To Range("range_results_details").Rows.Count - 1 Range("anchor_position_table").Offset(1, 7 + k).Value = Range("range_results_details").Cells(k, 1).Value Next k End Sub
Thanks,
Ayesha
Sub Add_Position() Dim i As Integer ' loop variable Dim k As Integer ' insert a new row into the table Range("anchor_position_table").Offset(1, 0).EntireRow.Select Selection.Copy Selection.Insert Shift:=xlDown Application.CutCopyMode = False Range("anchor_position_table").Select ' copy option details into the new row For i = 1 To Range("range_option_details").Rows.Count Range("anchor_position_table").Offset(1, i - 1).Value = Range("range_option_details").Cells(i, 1).Value Next i For k = 1 To Range("range_results_details").Rows.Count Range("anchor_position_table").Offset(1, 7 + k).Value = Range("range_results_details").Cells(k, 1).Value Next k End Sub
Shijesh Kumar
http://shijesh.wordpress.com/
Thanks so much, this works great.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks