-
Sep 25th, 2020, 01:50 AM
#1
Thread Starter
Junior Member
[RESOLVED] Looking to make this macro Faster
Code:
Sub STEP16()
Dim wb1 As Workbook
Dim ws1 As Worksheet
Set wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\HotStocks\1.xls")
Set ws1 = wb1.Worksheets.Item(1)
With ws1
Range("O2").Select
ActiveCell.FormulaR1C1 = "100"
Range("O2").Select
Selection.Copy
Range("K2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
End With
wb1.Save
wb1.Close
End Sub
-
Sep 25th, 2020, 03:37 AM
#2
Re: Looking to make this macro Faster
Not sure i understood what you're trying to do
Aircode:
Code:
......
Dim i As Long
With WS1
Range("O2")=100
For i=2 To UsedRange.Rows.Count
Range("K" & i)=Range("K" & i)*Range("O2")
Next
End With
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Sep 25th, 2020, 04:06 AM
#3
Re: Looking to make this macro Faster
depending how many rows are involved, i am sure it would be faster to to read the values into an array, do the calculation, then write the array back to the range
or probably even faster, use an array formula
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 28th, 2020, 01:26 AM
#4
Thread Starter
Junior Member
Re: Looking to make this macro Faster
Thnx Alot Both of u For ur Great Tips
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|