Streamline My Script

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
I use the following script a lot and get hassled for using it as it contains select etc...

Can anyone help streamline it so that it is more efficient.

Code:
Sub Test3()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Columns("O:O").Select
    Selection.NumberFormat = "General"
 
    Range("O2").Select
 
' want better way to select this column range using column to the left range
 
    ActiveCell.Offset(0, -1).Select
Cells(100000, ActiveCell.Column).Select
   Range(Selection, Selection.End(xlUp)).Select
   ActiveCell.Select
   ActiveCell.Offset(0, 1).Select
Set BottomCell = ActiveCell
    Set TopCell = Cells(2, ActiveCell.Column)
      Range(TopCell, BottomCell).Select
 
 
' want better way to fill selection
 
    Dim cell As Range
For Each cell In Selection.Cells
If cell.HasFormula = False Then
End If
 
 ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-14],C[1], 1, FALSE)"
ActiveCell.Offset(1, 0).Select
 
Next
 
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Code:
Sub Test3()

    Columns("O:O").NumberFormat = "General"
    Range("O2", Range("N" & Rows.Count).End(xlUp).Offset(, 1)).FormulaR1C1 = "=VLOOKUP(RC[-14],C[1], 1, FALSE)"
    
End Sub
 
Upvote 0
Wow!! That is great and super fast working on over 85000 lines.

Thanks heaps Alphafrog, it will come in very handy.
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,900
Members
449,194
Latest member
JayEggleton

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