background preloader

VBA Developer

Facebook Twitter

Merge or combine data and tables with Excel VBA macros. This page shows examples of how to merge and combine data and tables (lists) using criteria. You can also download workbooks with the examples. In the first example 2 tables/lists are merged to 1 with no duplicates. The new table is put in a new workbook and sorted. In the second example we loop 2 lists and make 2 new: One with the shared values and one with the values that are not shared.

The examples use arrays, ranges, collections, the worksheet function "CountIf" and loops. Merge to 1 table without duplicates This example requires some values (text or numbers) in cell A1 and down on sheet 1 and 2. You can also download a zip-compressed workbook (Excel 2003) with this and the next example. The code merges the values from 2 lists to 1 sorted list. 1: 2: 3: Donald Duck Donald Duck Batman Spiderman Spiderman Berlusconi Batman Berlusconi Donald Duck Spiderman Here comes the code. Find shared and not shared values in 2 lists Combine 2 tables Contacts | Company | Tel. | E-mail That was it. The Web Site of Professor Steven Roman. An enhanced object browser that shows a structured view of object libraries. From a Review of Object Model Browser in Microsoft Office & Visual Basic for Applications Developer June 2000 issue.

Object Model Browser (version 2) is a sweet little utility that will quickly replace the built-in VBE Object Browser as the tool of choice for examining the object structure of any library. This is a tool that a serious developer built to make his own life easier, then decided to share with the rest of us. You will be glad he did. (Reviewed by Lisa Z. Morgan) For the complete review, click OMB Review(The email in that review is no longer valid) Object Model Browser is designed to provide structured views of an object or type library, displaying the parent-child relationship among the objects in the library in a tree-like form.

What's New for Version 3 Version 3 of OMB has been totally rewritten under the .NET framework. Trial Version A trial version of OMB is available for download here. Dual Monitors And UserForms. Category: General VBA / UserForms | [Item URL] A UserForm object has a property named StartUpPosition. By default, this property is set to 1 (CenterOwner), which means that it should appear in the center of Excel's window. This works fine, unless you have a dual-monitor system. In such a case, the UserForm is not centered in the Excel window. On my system, UserForms always display on the left side of the secondary monitor, even if Excel is maximized on the primary monitor. To force an Excel UserForm to be centered in Excel's window, use this code to display the UserForm: With UserForm1 .StartUpPosition = 0 .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width) .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height) .Show End With I was hoping this would be fixed in Excel 2010, but nothing has changed.

Excel Tips Excel has a long history, and it continues to evolve and change. All Tips Browse Tips by Category Search for Tips Tip Books Needs tips? Free VBA Course. Collection Class (Microsoft.VisualBasic) Strings Class (Microsoft.VisualBasic) The Strings module contains procedures used to perform string operations. 'Declaration <StandardModuleAttribute> _ Public NotInheritable Class Strings The Strings type exposes the following members. This module supports the Visual Basic language keywords and run-time library members that manipulate strings. The following example demonstrates how to split a string at its spaces.

Dim TestString As String = "Look at these! " ' Returns an array containing "Look", "at", and "these! ". .NET Framework Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client Profile Supported in: 4, 3.5 SP1 .NET for Windows Store apps Supported in: Windows 8 .NET for Windows Phone apps Supported in: Windows Phone 8.1 Windows Phone 8.1, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported) VBA For Microsoft Excel: The Rows of a Spreadsheet. You can use just a few of the rows for your assignment but all of them are always available. When using a row, you can click it or use the keyboard to get to it. You can also right-click a row. When you do this, a menu would appear: To support the rows of a worksheet, the Worksheet class is equipped with a property named Rows.

Therefore, to refer to a row, you can use the Worksheets collection or the worksheet object to access the Rows property. To identify a row, indicate its worksheet and you can pass its number to the parentheses of the Rows collection. Sub Exercise() Workbooks.Item(1).Worksheets.Item(2).Rows(5) End Sub As reviewed for the columns, this code would work only if the second worksheet of the current workbook is displaying. As mentioned already, you can refer to a row using the Range object. Sub Exercise() Range("4:4") End Sub Sub Exercise() Dim SeriesOfRows As Range Set SeriesOfRows = Workbooks.Item(1).Worksheets.Item("Sheet1").Range("4:4") SeriesOfRows.Whatever End Sub.

Visual Basic Language Specification.