excel-vba

Excel, specify certain cell using Name field.

I created a macro that doesn't allow values in both the B and C columns of an Excel sheet. I want to make an exception to that formula by allowing cells with the names DayShift or AfterShift. I created this: If ActiveCell.Name = "DayShift" Or ActiveCell.Name = "AfterShift" Then But it doesn't seem to work and just makes other cells e...

selecting all cells in excel sheet from an offset (VBA)

So I am creating an excel report from an access database. So this is done in access VBA. Here is my code: Public Sub ExportActiveSheet() 'irrelevant data 'get the info ExcelSheet.Range("A3").CopyFromRecordset rs Set rs = Nothing End Sub so now, as you can see.. my recordset gets copied to a range starting from A3. ...

Generate word documents from excel file using mail merge

Hello I am trying to generate word documents using the mail merge feature in Microsoft Word. To be as clear as possible my dream would be to: (1) Place all values for all documents to be created in one excel document (2) Use Word to create a template by selecting the above excel file as the data sheet (3) Run a macro that would use th...

Is it possible to run a macro in Excel from external command?

Let's say I want to program a VBA code in an external program that opens an Excel file, runs a macro, saves (and say yes to any pop up windows), and close Excel. Is it possible to do so? If so, how would I go about implementing it? ...

Table heirarchy in Excel, using Excel as a form with repeating tables

Hi, I am creating a form using Excel. The form will be populated upon creation from outside data, but there will be room for users to enter (but not remove info). I need to have repeating tables. I have created my own version of repeating tables( not using Excel's concept of "table") and I have hyperlinks at the bottom of each table t...

How to make a listview in excel selectable but not editable in office 2007

I have a userform that allows the user to select customers from a combobox; when a customer is selected, the customer's offices (office name, city, state, address) populate a listview in Report mode. I would like the user to then be able to select (click on) a row in the listview, which triggers code that populates the office-related co...

VBA excel - using a variable to select a column range

VBA - The user selects a number from a combobox (1-50) and it is assigned as a variable. I now want to program a function which selects columns BA to a column to the left whatever value the user selected (I.E. from AV:BA where AV is the variable column). I have the variable the user slects as a string (dim var as string). Your help would...

Creating a time handling function (Excel VBA)

I have a few cells that schedule a list of employees depending on a start time. (In this case, the start time is indicated by the cell named 'Time'.) =CONCATENATE(TEXT(Time,"h:mm AM/PM")&" - "&TEXT(Time+TIME(10,30,0),"h:mm AM/PM")) It works fine but now I want to implement a feature that will allow the user to specify how long the shi...

How do I keep all the leading zeros on a Hexadecimal Range in VBA?

Hi There, I am trying to expand a range of Hexadecimal numbers. For example I have on column K ... 1880 and column L ...188A my range is 1880-188A When I expand the Range, starting On column M I get 1880 1881 1882 1883 1884 1885 1886 etc etc. From one of the posting I copied and changed the VBA script to fit my case... and it works ....

Excel VBA: Getting the average of a column with unknown size

I am writing a Macro that requires me to get the average of the values in a column with an unknown number of rows. I use this to get the number of the last row: Dim lastRow As Long lastRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row That works. What doesn't work is when I try to use it here: Range("B2").Select Activ...

Excel: Sort columns by row content

Hi, it's hard to describe. I have some columns, say three: 10 20 20 20 22 24 24 24 26 What I like to get is: 10 XX XX 20 20 20 XX 22 XX 24 24 24 XX XX 26 where XX is an empty cell. Is there a way to get this? Bye, Thomas ...

Excel 2003: Double clicking a cell to change another cell's content in another worksheet

All I'm trying to do is figure out how to change the cell in one worksheet to that of another when the one in the other is double clicked. In my second worksheet, I have the following code set up: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) End Sub My question would be what's the code to chan...

Excel VBA Double Addition Error

I'm having a hard time explaining this one. The following function is being used as a worksheet formula. A value of "empty" simply means that the cell was empty and, therefore, there is no value. Given the values {empty, empty, 0.8, 0.2}, the following function is sometimes returning off the wall values like 5.55111512312578E-17. In ...

Where do I get started with VBA and macros programming in Word 2007?

I just came to know that macros in Word/Excel/PowerPoint can be programmed. That is awesome because I've a Word document with 70 tables for styling. I'm a programmer but I don't know VB, VBA or VB .NET. I'm confused with these three. I'm familiar with .NET programming using C#. Now I want to write new macros. Where should I get started?...

How to print from excel to pdf without typing in a filename

Is there a way to get around having to type in a filename when sending a document to Adobe PDF printers? My code is: Application.ActivePrinter = "Adobe PDF on Ne01:" MyWorkbook.PrintOut From:=1, To:=3, Copies:=2, Collate:=True This works except that it prompts me for a filename. Would rather find a way to fix this without installing a...

Excel - Creating a print macro

I recorded a macro to print an excel sheet when the button is pressed. But I want to specify the printer that it automatically prints to rather than give the user a choice. I'm also printing to a PDF so is there a way I can choose where I print to? This is what I have so far: Sub Publish() ' ' Publish Macro ' Macro recorded...

Where to store DB connection string for Excel 2007 Template App Connection to SQL Server Database?

I have a legacy Excel 2007 Template that has hardcoded Ms Access MDB path in the VBA code used to connect to the Access tables and save, retrieve data. I migrated the MS Access Database over to SQL Server with Integrated Authentication for the Excel 2007 Template Users. My question is, What is the Recommend Way / Best Practice for stor...

Auto Calculation though vba code

I have a excel workbook consisting of 3 sheets. One sheet name is 'importeddata' in which 10 columns exist starting from b5 to k1000(b5:k5 is the heading of the columns). Another sheet name is 'Main Form' in which 10 columns exist starting from b5:K1000. Now i want to put 'column (c6:c1000) and column (g6:g1000)of the importedata sheet d...

Copy Excel Worksheet from one Workbook to another with Powershell

Hi, I'd like to copy (or move) a worksheet from one workbook to another workbook with Powershell. I had done this before and cant remember how. I think I used CopyTo() funtion. Just to get started. $missing = [System.Type]::missing $excel = New-Object -Com Excel.Application $wb1 = $excel.Workbooks.Add($missing) $wb2 = $excel.Workboo...

excel combo box populate

Hi In my excel sheet1 i have 2 combo box... 1)When i open the excel the 2 combox has to fill 2)if i select one value in one combo box the corressponding should populate in the second combo box ...