vba

How do I make sure public VBA methods don't show up in the list of Excel macros?

In Excel VBA (2003), I've noticed that any Public or Friend Sub method in either a module or ThisWorkbook that doesn't have any arguments will show up as a Macro that can be run by the user. I.e. when the user goes to Tools --> Macro --> Macros... (or Alt+F8) the method will show up in the list that can be run. For sanity's sake (organ...

How to place text in the clipboard so that it pastes as a table in Word?

Using VBA in MS Office, how do I add text to the Windows clipboard so that it will paste into Word as a table? ...

VBA long overflow

Hi I am trying to do some maths with my VBA excel (prime factorization) and I am hitting the limit of the long data type (runtime error 6 Overflow). Is there any way to get around this and still stay within VBA? (I am aware that the obvious one would be to use another more appropriate programming language) Thanks for help in advance! ...

Access VBA: How to select particular columns in ado using getstring?

Hi, When we use getstring to get data from a recordset(ADO) then it returns all the columns, if only particular columns are required then how do we modify the getstring statement?# Thanks tksy ...

VBA Access 2003 table with a variable number of Columns

I have a table in Access 2003 VBA with 164 columns but the data I get has 181 column and it is possible that it will get bigger in the future. I need to know how to resize my table an to add extra colums during the runtime I know how to check how many colums I need so I just need to know how to resize my own table. thanks ...

How to import a files like PDF MP3 DOC XLS into a MS SQL Server Datatable field using VBA code in Access2007

Hi, does anybody know how to save and retieve files in MS SQL-Server 2000? I guess the image data type could be used as a container. I want to import/export the following file types: DOC, XLS, PDF, BMP, TIFF, etc. Due to resource issues we are using MS-Access2007 as the front end, so I am looking for VBA code. Thanks in Advance. ...

Excel 2002 Web Query screwing up en-GB dates

Good afternoon, I have a web query in Excel 2002 going against a web page that returns a date column. The dates are returned as DD/MM/YYYY, as I would like to show them in my spreadsheet. My machine running Excel has its regional settings set to en-GB, and the only language set under Internet Options is UK English. Nevertheless, the ...

Failure to Pass Arguments to a UDF in VBA for Excel 2007

I have a complex iterative spreadsheet in which I want to use a UDF to calculate the heat transfer coefficient of a heat exchanger. The function has 5 arguments (2 strings and 3 doubles). The strings and 1 double pass just fine. The remaining two don't seem to go through at all. A watch on problematic arguments shows them to be equal to ...

Excel 2000 VBA: Errors Raised within Class Debug As If Raised at Property Call

I am (unfortunately) developing an application in Excel 2000 VBA. I believe I have discovered that any error raised within a Custom Class property, function, or sub debugs as if the error were raised at the point in the VBA code where the property is called. That is, the VBE debugger does not take me to the point in the Class property ...

MSXML2.XMLHTTP send method works with early binding, fails with late binding

The code below works. But if I comment out the line "Dim objRequest As MSXML2.XMLHTTP" and uncomment the line "Dim objRequest As Object" it fails with the error message "the parameter is incorrect". Why, and what (if anything) can I do about it? Public Function GetSessionId(strApiId, strUserName, strPassword) As String Dim strPostData ...

Adding Custom Autotext for MS Word

I need to know how to add a custom, dynamic Autotext entry for Microsoft Word. I want to be able to Insert>Autotext>Header/Footer>"Last Friday" and have last Friday's date show up in the spot and keep it updated like inserting the Date Autotext updates each time the document is opened. I have the VB code necessary to compute last Frida...

Misunderstanding of Long data type in VBA

From the help for the Overflow Error in VBA, there's the following examples: Dim x As Long x = 2000 * 365 ' gives an error Dim x As Long x = CLng(2000) * 365 ' fine I would have thought that, since the Long data type is supposed to be able to hold 32-bit numbers, that the first example would work fine. I ask this because I have some...

How to sum data in one column based on the same month in another column using macros

Hello I am Tifu, I am using macros in excel 2007 for my work. I am working with many data and I need to sum data from 2 or more rows in the same coloumn according to the same month. However the month column is expressed as date. for example, i have series of data A B 2/10/2008 2 2/10/2008 3 4/10/2008 3 5/11/2008 ...

Is it possible to use a string as an index in VBA?

In other languages you can use strings as keys: PHP: $array['string'] = 50; $array['anotherstring'] = 150; Is this possible in VBA? ...

Make Word's Cursor Type (Or More Text Insert) in Non-Italic After Turning Text Italic

Hello, When I perform the following code: Dim italicSaveRange As Word.Range Dim savedItalic As Variant Dim someRange As Word.Range Set italicSaveRange = someRange.Duplicate italicSaveRange.Collapse (WdCollapseEnd) savedItalic = italicSaveRange.Italic someRange.Italic = True italicSaveRange.Italic = savedItalic I expected that any te...

vba problem using case to colour range based on number in cell

hi using macro i have consolidated info from several wbooks into on sheet in new book. in one column i have created a named range called ColRange i have numbers ranging from -350 to 500 in this column I can't seem to write the vba to color these cells red(0-500) yellow(-5-0)and green(-350--5) any help would be appreciated thanks ...

How do I convince a manager we need bug tracking software?

Good day all, I'm the "lead developer" for a major Excel based application that handles the production of a few mine sites. It talks to a bunch of databases, tries its best to help out users, and generally clunks along just fine through a mix of Solver, VBA, and in cell formulas. Our development team is tiny and is composed entirely of...

HP Universal Printer Driver- any thoughts/advice?

We, like most companies enforce a branding policy on our outgoing literature. This involves using different paper types etc, so we need to control the print process using a shared set of VBA routines stored in addin templates. One of the main problems we face is the nuances (such as hard coded tray enumerations) between different models'...

VBA: How to round to nearest 5? (or 10 or X)

Given numbers like 499, 73433, 2348 what VBA can I use to round to the nearest 5 or 10? or an abitrary number? By 5: 499 -> 500 2348 -> 2350 7343 -> 7345 By 10: 499 -> 500 2348 -> 2350 7343 -> 7340 etc. Integrated Answer X = 1234 'number to round N = 5 'rounding factor round(X/N)*N 'result is 1235 For floating point t...

SQL-WHERE TYPE Formulas in Excel

Let say I have a sheet in with columns Customer and CreatedDate with lots of row with data. Anyone who knows how to setup (through VBA or Formula) a second sheet that displays rows from the first sheet based on certain where statements, i.e. all rows with customers "created this month." (similar to a select ... where query against a SQL ...