I want to copy and paste the formula in alternate row without breaking the link.
I have attached an example with explanation. Please help!
This is required for a range of more than 1000 rows & i want to create a macro for this.
I want to copy and paste the formula in alternate row without breaking the link.
I have attached an example with explanation. Please help!
This is required for a range of more than 1000 rows & i want to create a macro for this.
When you copy to Row 9, what do you want the reference to be? 7 or 8.When I copy from Row 5 to Row 7, formula is linking to row 7 of input file
Where as I want the formula to be linked to row 6 of input file.
And to Row 11, 8, 9 or 10
Would this work?
Sub Expand_Formulae() Dim Message, Title, Default, MyValue, i As Long, j As Long Message = "Please enter the Row number you want to expand to" Title = "Use an odd number please" Default = "" MyValue = InputBox(Message, Title, Default) Application.ScreenUpdating = False Range("A5:K5").Value = "=Input!RC" j = 1 For i = 7 To MyValue Step 2 Range("A" & i & ":K" & i).Value = "=Input!R[-" & j & "]C" j = j + 1 Next i Application.ScreenUpdating = True End Sub
See attached
Thank you Jolivanes. This will help me a lot. However, i have one more query.
Instead of manually updating the no. of rows everytime i click the expand button, is it possible to apply this logic through macro with a predefined range.
For example: I want to copy the data from row 5 and paste in alternate row till row 55. Here 55 is already predefined and in the single click the data should get copied in alternate row upto row 55.
Try this.
Sub Expand_Formulae_A() Dim i As Long, j As Long Application.ScreenUpdating = False Range("A5:K5").Value = "=Input!RC" j = 1 For i = 7 To 55 Step 2 Range("A" & i & ":K" & i).Value = "=Input!R[-" & j & "]C" j = j + 1 Next i Application.ScreenUpdating = True End Sub
Glad you've got it working.
Thanks for letting us know.
Good luck