+1 vote
in VBA by Beginner (6 points)

Believe there's a method run the script below, but using the Evaluate function. Below works, but I'm hoping it could run quicker.

    For i = 2 To lrBP
        For j = 7 To lrBdg
            If shBP.Range("A" & i) = shBdg.Range("B" & j) Then
                shBP.Range("B" & i).Copy
                shBdg.Range("AA" & j).PasteSpecial xlPasteValues
            End If
        Next j
    Next i

 

3 Answers

+1 vote
by Beginner (56 points)
selected by
 
Best answer

Try this.. it should speed up the processing of the loops:

Application.ScreenUpdating = False
Application.Calculation = xlManual
    'your code here..
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic

Also, you could read your range into an array, as in:

dim arr() as variant
arr() = Range("your range here").Value

.. and then process your calculations within the array and write the results from the array back out to the worksheet. This would be faster than doing a copy/paste loop directly on the face of the worksheet. Would need a little more context from your example to actually write the code/solution.

Hope this helps. Good luck.

0 votes
by Skilled (366 points)

Not sure if this will work, but see How to Change Another Cell with a VBA Function.

0 votes
by Beginner (4 points)

This bit of code searched 2 columns G:H for teh occurance of 2 dots and replaces them with 1 dot

    Columns("G:H").Select
    Selection.Replace What:="..", Replacement:=".", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False

 

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Getting Started
Register
VBA Cheat Sheets (On Sale Now)

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

Looking for something else? Hire our professional VBA Help, instead.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and answers. All you have to do is post and you could get rewarded, like these members:

Hightree $10 Amazon Gift Card
Thales1 $10 Amazon Gift Card
runfunke $10 Amazon Gift Card
coolag $10 Amazon Gift Card
Siew Hun $10 Amazon Gift Card

So, why don't you join us? It really is an encouraging way to motivate members in our VBA and Python community.

Register

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.

...