Macro procedure too large.... how can I shorten?

sfried

New Member
Joined
Sep 24, 2013
Messages
9
My spreadsheet has a specific macro embedded in it that I want to run many times (the command sets several items in the current row on spreadsheet, and then jumps to next row).
I set up my own macro to run the command many times in succession (for many rows). It sets calculation to Manual, then runs the command many times, and then put calculation back to automatic. This works fine for up to 300 times. But when I tried increasing to do 1,000 times, it became too big (Got "Compile Error: Procedure too large").

I imagine there's a better formula to create in the macro to run this. Can anyone help?

The Existing Macro I created to run 5 times.
Sub
Application.Calculation = xlManual


Range("c21").Select
Application.Run "'aaaStockMaster-andIB-all-2.xlsm'!Sheet1.requestGenericTicks"
Application.Run "'aaaStockMaster-andIB-all-2.xlsm'!Sheet1.requestGenericTicks"
Application.Run "'aaaStockMaster-andIB-all-2.xlsm'!Sheet1.requestGenericTicks"
Application.Run "'aaaStockMaster-andIB-all-2.xlsm'!Sheet1.requestGenericTicks"
Application.Run "'aaaStockMaster-andIB-all-2.xlsm'!Sheet1.requestGenericTicks"
Application.Run "'aaaStockMaster-andIB-all-2.xlsm'!Sheet1.requestGenericTicks"

Application.Calculation = xlAutomatic
End Sub

Using Excel 2007, windows Vista.






The command under requestGenericTicks is below (not sure you need this, but just in case)
Sub requestGenericTicks()
Dim server As String, req As String, reqType As String, id As String, secType As String, genericTicks
Dim delimiter As String
Dim i, j As Integer
Dim genericTicksArray() As String
Dim genericTicksRequestString As String
Dim supportedGenericTicksArray(0, 1) As Variant
supportedGenericTicksArray(0, 0) = 18 ' column offset for lastRthTrade
supportedGenericTicksArray(0, 1) = "318" ' lastRthTrade

server = util.getServerStr(serverCell)
If server = "" Then Exit Sub
Dim setSecType As String, setExchange As String
If Not util.composeContractReq(ActiveCell, req, reqType, True, , , , setSecType, setExchange) Then Exit Sub
id = util.getIDpost(genId)

' add generic ticks
genericTicks = ActiveCell.offset(0, 13).value
If genericTicks <> "" Then
delimiter = ","

' parse generic ticks string into array
genericTicksArray = VBA.Split(genericTicks, delimiter)

' check if generic tick is supported
Dim composeControlLink As Boolean
composeControlLink = False
For i = LBound(genericTicksArray) To UBound(genericTicksArray)
For j = LBound(supportedGenericTicksArray, 1) To UBound(supportedGenericTicksArray, 1)
If genericTicksArray(i) = supportedGenericTicksArray(j, 1) Then
genericTicksRequestString = genericTicksRequestString & genericTicksArray(i) & delimiter
ActiveCell.offset(0, reqOffset + supportedGenericTicksArray(j, 0)).Formula = util.composeLink(server, topicGenericTicks, id, supportedGenericTicksArray(j, 1))
composeControlLink = True
End If
Next
Next
If composeControlLink Then
genericTicksRequestString = Left(genericTicksRequestString, Len(genericTicksRequestString) - 1)
ActiveCell.offset(0, reqOffset + 1).Formula = util.composeControlLink(server, topicGenericTicks, id, reqType & "?" & genericTicksRequestString, req)
End If

End If

ActiveCell.offset(1, 0).Activate
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Where is all this code located?

the GenericTick command line comes from an excel spreadsheet I got from a service provider... that runs some specific stuff related to the service provider's product. I'm not looking for work on that.

The macro I created, which I'm looking for help with.... runs the GenericTick command, MANY times in succession (1x for each row). I'm planning to have it run for 1,100 rows.
 
Upvote 0
If you just want to run a line of code multiple times use a loop.
Code:
For I = 1 To 10000
    Application.Run "'aaaStockMaster-andIB-all-2.xlsm'!Sheet1.requestGenericTicks"
Next I
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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