VBA procedure too large

phil133

Active Member
Joined
May 5, 2015
Messages
257
Office Version
  1. 365
Platform
  1. Windows
Hi. I get the error that my procedure is too large. What I'm doing is copy pasting values from N to O only in even rows starting from 6. Please how can I reduce the procedure? Thanks for any help!

Code:
Selection.Copy
    Range("O6").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("N8").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("O8").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("N10").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("O10").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("N12").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("O12").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
 
Perhaps this:
Code:
Sub m()
Dim i As Long
MsgBox Range("N" & Rows.Count).End(xlUp).Row
For i = 6 To Range("N" & Rows.Count).End(xlUp).Row Step 2
    Range("O" & i).Value = Range("N" & i).Value
    Range("N" & i + 2).Calculate
Next i
End Sub
 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Thanks for your answer. This returns 51. The number of rows. If I delete the MsgBox line the result is the same with before. It copy pastes values without calculating first.
 
Upvote 0
Then I think you either need to fix your circular reference, or turn iterations on. Why do you have a circular reference?
 
Upvote 0
I'm trying to backtest a strategy of selling options of a stock. So if (G6*H6)=I6 is lower than K5 (not a constant number) then G6 should be the ABS(K5)/I6. Do you mind if I paste a link from my file on dropbox so you see what happens?
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,792
Members
449,048
Latest member
greyangel23

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