Problem with formulas in cells after macro

Alpacino

Well-known Member
Joined
Mar 16, 2011
Messages
511
I have just have a macro that populated cells "A2:O15" with ramdom numbers from 1 to 14. Underneath this I have formulas in cells vlookup but after I run the marco after clearing "A2:O15" cells. The formulas dont work. I have to click the cells with formulas in and clock on formula and return it for it to work
Any ideas why this has happened??
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Alpacino,

Can we see your macro code?

If posting VBA code, please use Code Tags, see below in my Signature block: If posting VBA code, please use Code Tags - like this
 
Upvote 0
Thanks for reply. This is the code

Sub randnames
Range("C2").Select
ActiveCell.FormulaR1C1 = "=TRUNC(RAND()*10)"
Range("C2").Select
Selection.AutoFill Destination:=Range("C2:C11"), Type:=xlFillDefault
Range("C2:C11").Select

With Application
.Calculation = xlManual
.MaxChange = 0.001
.CalculateBeforeSave = False
End With
For y = 2 To 10
Cells(y, 3).Select
If Cells(y, 3) = Cells(y + 1, 3) Then
Calculate
y = 1
Else
For x = y To 10
If Cells(y, 3) = Cells(x + 1, 3) Then
Calculate
y = 1
End If
Next x
End If
Next y
Range("C2:C11").Select
Range("C11").Activate
Selection.Copy
Cells(2,i).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Next i
End Sub

The
 
Upvote 0
At the start of the code should say for i = 3 to 11 Step 2

Underneath the column that response to the step in the for i there is a vlookup formula. Eg in column C row 13 and onwards there is =VLOOKUP(B13,C2:O11,12,0)
 
Upvote 0
Alpacino,

Your code is not complete.

You are missing the beginning code for the i loop:


Rich (BB code):
For i = ? To ?


Next i



Please wrap your code in code tags.

If posting VBA code, please use Code Tags, see below in my Signature block: If posting VBA code, please use Code Tags - like this
 
Upvote 0
Alpacino,

I am not going to guess where that line of code goes.

Please post all your macro code, and wrap your code in code tags.

If posting VBA code, please use Code Tags, see below in my Signature block: If posting VBA code, please use Code Tags - like this
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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