PDA

View Full Version : Solved: VBA pastes in wrong range



Tuneman12
03-24-2009, 09:31 AM
When my code gets to the **** line, it doesn't paste it in b5:b11, it is in a random row that changes every time.

Sub Calculate()

Dim x
x = 0


Do While x < 30

Range(Cells(6, 3 + x), Cells(12, 3 + x)).Copy

Sheets("Monte Carlo Sim").Select
********Range("B5:B11").PasteSpecial Paste:=xlPasteValues

Calculate
Range("DA40005").Copy
Range("I40010").PasteSpecial Paste:=xlPasteValues

Calculate
Range("DA40005").Copy
Range("I40011").PasteSpecial Paste:=xlPasteValues

Range("B5").Value = Range("B5").Value + 1

Calculate
Range("DA40005").Copy
Range("J40010").PasteSpecial Paste:=xlPasteValues

Calculate
Range("DA40005").Copy
Range("J40011").PasteSpecial Paste:=xlPasteValues


Range("K40013").Copy
Worksheets("Main").Cells(19, 3 + x).PasteSpecial Paste:=xlPasteValues

x = x + 2

Loop


End Sub

Bob Phillips
03-24-2009, 09:34 AM
Get outta here!

Post your workbook for us to see.

Tuneman12
03-24-2009, 09:57 AM
I can't its 80mb. But actually this version freezes excel and forces me to ctrl-alt-del

When it said this it would go to a wierd cell
Sheets("Monte Carlo Sim").Select
Selection.Range("B5:B11").PasteSpecial Paste:=xlPasteValue