Generate a Random Number Between Two Values
May 16th, 2007Here's a quick and easy VB function to generate a random number between two values that you specify.
Dim r As New Random(System.DateTime.Now.Millisecond)
Return r.Next(iMinValue, iMaxValue)
End Function
Break Links to another workbook
May 1st, 2007Sometimes, you get a workbook with links to many other workbooks that you don't need or don't have. It's easy to break the links through the user interface (Edit->Links) but if there's a lot of links you need to break, it can be annoying. Specially if you have to do it over and over again. So here's a short procedure to break all external links in the currently active workbook.
Dim Links As Variant
Dim i As Integer
With ActiveWorkbook
Links = .LinkSources(xlExcelLinks)
If Not IsEmpty(Links) Then
For i = 1 To UBound(Links)
.BreakLink Links(i), xlLinkTypeExcelLinks
Next i
End If
End With
End Sub
Create an Excel File from Visual Basic
April 25th, 2007Creating and working with Excel files from Visual Basic is very easy. To demonstrate, let's create a very simple console application that will create an excel workbook, "HelloWorld.xls". In Sheet1!A1 of the workbook, we'll put the words "Hello, World".
Here's how.
1. In Visual Basic 2005 Express, create a new console application.
2. Add a reference to the Microsoft Excel Object Library.

Continue reading Create an Excel File from Visual Basic...
Posted in Excel, How To, Visual Basic | No Comments« Previous Page — Next Page »
(C) by Virgilio Adriano. All rights reserved. Powered by WordPress.
Entries and comments feeds.
It took 0.364 seconds to load this page.