Serving the Quantitative Finance Community

Search found 13 matches

by jpsnj
December 22nd, 2010, 4:19 pm
Forum: Programming and Software Forum
Topic: Excel automation
Replies: 7
Views: 24342

Excel automation

<t>This may get you started:Let's assume you have Sheet1 and Sheet2 with data on both sheets in columns A through FStep 1: Copy the function below into a VBA code moduleFunction Mtch(sourcerow As Range, ansrows As Range) As Long Application.Volatile True Dim rw As Range, n For Each rw In ansrows.Row...
by jpsnj
November 4th, 2010, 3:13 pm
Forum: Programming and Software Forum
Topic: Last cell with value in a collumn, VBA
Replies: 4
Views: 26458

Last cell with value in a collumn, VBA

<t>The two subs below should be enough to get you started.Sub GetLastRowAndCol() Dim lastCol As Long Dim Lastrow As Long On Error GoTo x lastCol = ActiveSheet.Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column Lastrow = ActiveSheet.Cells.Find("*", SearchOrder:=xlByRows, Se...
by jpsnj
October 15th, 2010, 12:12 pm
Forum: Programming and Software Forum
Topic: Textbox dictates the range of timeseries VBA
Replies: 4
Views: 25272

Textbox dictates the range of timeseries VBA

<t>You can use the Application.Inputbox function to prompt the user to select a range. Note: The Application.Inputbox is different than the VBA InputBox.Using this method, the user can either manually enter a range such as B2:B500 or select it with the mouse.A couple of examples are below:Sub Select...
by jpsnj
August 27th, 2010, 1:18 pm
Forum: Programming and Software Forum
Topic: VBA code: Multiple Excel-files
Replies: 2
Views: 24790

VBA code: Multiple Excel-files

<t>The sub below will loop through all files in a directory and copy data into a line on a worksheet. It is set to copy data from five cells in a worksheet to a line in the master workbook. Change the example to fit your needs.Sub CopyData()Dim lngCtr As LongDim wksPaste As WorksheetDim sPath As Str...
by jpsnj
January 19th, 2010, 8:29 pm
Forum: Programming and Software Forum
Topic: Excel VBA: Keyboad shortcut to scroll through formatting
Replies: 2
Views: 33573

Excel VBA: Keyboad shortcut to scroll through formatting

Ctrl/Shift 1,Ctrl/Shift 2,Ctrl/Shift 3,Ctrl/Shift 4,Ctrl/Shift 5,Ctrl/Shift 6 will provide 6 different number formats for a selected cell.
by jpsnj
December 17th, 2009, 12:17 pm
Forum: Programming and Software Forum
Topic: Excel question
Replies: 5
Views: 32949

Excel question

Enter this in the data validation formula (Data/Validation/Custom/Formula) in cell A1 and copy all the way down.=COUNTIF(A:A,A1)=1
by jpsnj
November 18th, 2009, 1:51 pm
Forum: Programming and Software Forum
Topic: Basic Formatting in excel
Replies: 4
Views: 33416

Basic Formatting in excel

<t>This may get you started.Place this code in a standard module:=============Public r As RangePublic Function MyCalc(i, j)If r Is Nothing Then Set r = Application.ThisCellElse Set r = Union(r, Application.ThisCell)End IfMyCalc = i * jEnd Function============Place the code below in the "ThisWorkbook...
by jpsnj
October 28th, 2009, 4:47 pm
Forum: Programming and Software Forum
Topic: VBA coding question
Replies: 2
Views: 33849

VBA coding question

<t>A routine in the open event like the code below will be effective with 99% of the users. Private Sub Workbook_Open() Dim i As Integer i = Val(GetSetting("MyApp", "MySection", "Counter", 0)) If i >= 5 Then ThisWorkbook.Saved = True ThisWorkbook.Close False Else i = i + 1 SaveSetting "MyApp", "MySe...
by jpsnj
January 26th, 2009, 9:37 pm
Forum: Programming and Software Forum
Topic: VBA: Automatically divide specific values
Replies: 1
Views: 44317

VBA: Automatically divide specific values

<t>This may get you started:Sub abc() Const CRIT As String = "=CS2YAH*" Dim ws1 As Worksheet Dim ws2 As Worksheet Dim lngCount As Long Dim rng1 As Range, rng2 As Range Set ws1 = ActiveSheet Set ws2 = ActiveWorkbook.Worksheets.Add ws2.Name = "ProblematicISINs" ws1.Range("A1").AutoFilter Field:=1, Cri...
by jpsnj
January 13th, 2009, 9:43 pm
Forum: General Forum
Topic: Bloomberg VBA Refreshing data and Saving
Replies: 1
Views: 54113

Bloomberg VBA Refreshing data and Saving

Try the code belowSub refreshLinks()Workbooks.Open Filename:= _"C:\Investments\test.xls", UpdateLinks:=3Application.Run "blpmain.xla!RefreshAllStaticData"Application.OnTime Now, "DoClose"End SubSub DoClose() ActiveWorkbook.Save ActiveWorkbook.Close FalseEnd Sub
by jpsnj
December 1st, 2008, 2:16 pm
Forum: Programming and Software Forum
Topic: Couple of simple VBA questions
Replies: 4
Views: 46670

Couple of simple VBA questions

vector = Array(1, 2, 3, 4, 5)Range("A1:A" & UBound(vector) + 1).Value = Application.Transpose(vector) ORRange("A1").Resize(UBound(vector) + 1, 1).Value = Application.Transpose(vector)
by jpsnj
June 20th, 2008, 1:35 pm
Forum: Programming and Software Forum
Topic: Hard Excel Interview questions
Replies: 20
Views: 59625

Hard Excel Interview questions

<t>I don't think your questions are too tough. I ask them to write a simple routine in VBA such as removing leading and trailing spaces from A1:Z10000There are many ways to do this and I can usually guage a person's level by the method they use.If they write something similar to Sub A, they are "tra...
by jpsnj
February 14th, 2008, 6:21 pm
Forum: Programming and Software Forum
Topic: Scary Spreadsheets
Replies: 16
Views: 63582

Scary Spreadsheets

The department I work for at an accounting firm builds spreadsheet apps with best practices and stringent development standards. I never encountered this while I was an Excel jockey for a trading desk at a bank.