vba

How to wrap images into a Excel Add-in 2003

hi, I'm having a excel add-in with several menu items. Each menu item embedded with a image. I'm loading picture to menu item using LoadPicture function where I gave the absolute path to image location. In order to make the add-in distributable I need to provide a relative path. Appropriate anyone can suggest me how to do this. Thank ...

Add Contents of Cell to VBA Query

I would like to update my code to include the contents of a cell, S3. Right now the cell has the value of 'Test, Testing, Tested' and the relevant part of the query looks like this: SELECT * FROM dbo.Total WHERE ID = " & TextBox1.Text & " And Source IN (What do I put in here?) Your help is much appreciated ...

Create Macro With Several Variables

I have several worksheets with similar code, so I'd like to turn it into a macro. My only problem is that there are several variables. So at certain points the code looks like this: Dim Msg1 As String Dim Msg2 As String Public Sub ListBox1_LostFocus() ListBox1.Height = 15 With ListBox1 Msg1 = "'" For i = 0 To .ListCount - 1 ...

access forms: forcing UCASE in a textbox

i would like to force the textbox to immediately change the text to UCASE as soon as the user moves away from the field. is this possible? the important thing is that this text will be used in a SQL query to update a table. ...

ms-access: difference between .value and .text

i am passing values from a textbox into a sql statement in ACCESS i do not understand the difference in the usage of these two properties when i set the the .text property to something, how does the .value property get affected? when i do want something to be displayed in the textbox should i be using the value or text property? ...

How do I search & replace all occurrences of a string in a ms word doc with python?

Hello there, I am pretty stumped at the moment. Based on http://stackoverflow.com/questions/1045628/can-i-use-win32-com-to-replace-text-inside-a-word-document I was able to code a simple template system that generates word docs out of a template word doc (in Python). My problem is that text in "Text Fields" is not find that way. Even i...

VBA - Stop program from quitting, minimize instead.

Hi all. I want to write a macro for Outlook that is called when I click the X. I want the Application_Quit() subroutine to stop the program from quitting, then minimize it instead. I can figure out the minimization, but how to I prevent it from quitting? ...

How to compare 2 similar strings letter by letter and highlight the differences?

We have 2 databases that should have matching tables. I have an (In-Production) report that compares these fields and displays them to the user in an MS-Access form (continuous form style) for correction. This is all well and good except it can be difficult to find the differences. How can I format these fields to bold/italicize/colo...

excel vba: setting the formula to equal A or B if not found A

i have a vba line of code like this: ActiveCell.FormulaR1C1 = "=LOOKUP(""ETG_C"",RC[-10],RC[-8])" i would like to know how is it possible to have the activecell formula be something else in the case that it does not find ETG_C for example: =if(not(LOOKUP(""ETG_C"",RC[-10],RC[-8]))) then =LOOKUP(""something_else"",RC[-10],RC[-8]) ...

translating LOOKUP from VBA into excel formula

i have a formula that looks like this in VBA: ActiveCell.FormulaR1C1 = "=LOOKUP(""ETG_C"",RC[-10],RC[-8])" what would be the exact equivalent of this if i simply input it into the worksheet? ...

excel IF formula question

i am building a formula like this: =if(a1="something" or a1="alex","returned","not found") but i guess the syntax is wrong. what is the correct way to write this? ...

IF , OR formula not working in VBA

i have this formula in VBA: ActiveCell.FormulaR1C1 = "=IF(OR(A2=""ETG_C"",A2=""ETGC""),C2,""na"")" when i look at the activecell it actually returns this formula: =IF(OR('A2'="ETG_C",'A2'="ETGC"),$B:$B,"na") how do i force it to adhere to the first formula? ...

Return values only if they are not present in current column

I have a column to which I am adding data from another column I would like to check whether that column has the data that I wish to add. Can you help me with a formula that will tell me whether a certain value exists in the current column? Please keep in mind it is a bit more complex than it sounds. Currently I have this in the cell: ...

Find file that could be in one of three locations

i need to write a vba script that will find a file. the file could be in three different locations how do i find where the file is? the file must have a specific string as part of the file name my file name could be 9424.bas or 9424a.esy or 9424_.bas or 9424...esy, i dotn know what the file name exactly is but i know the important cha...

vba: how do i open a file if i only know part of the file name?

i need to open a file whose full filename i do not know i know the file name is soemthing like filename*esy i know definitely that there's only one occurrence of this file in the given directory ...

Spreadsheet component with VBA support

I am looking for a .Net spreadsheet component that could also execute the VBA contained in Excel files. I found Spreadsheet Gears to be very nice for manipulating and allowing the user to edit Excel files, but on spreadsheets that use VBA for calculations, well, these don't work. So, apart from Excel itself, are there any other compone...

Excel VBA: NetworkDays Error 2015

Hi All, I have the this bit of code in a VBA class which is to workout the number of days between a property of the class (a date) and today’s date. Dim EmailDate As Date EmailDate = Me.Email.DateReceived Debug.Print EmailDate, Date Debug.Print NetworkDays(EmailDate), Date, Range("BankHolidays")) When I run it I get the following ou...

How do I run some VBA code when a cell is changed?

I want to add some VBA code when the value in a cell changes. I've already tried Worksheet_Change(), as described at http://www.contextures.com/xlfaqmac.html#WSChange However, this won't work: it only fires when the user changes the value. I want to fire it whenever the value changes, i.e. whenever the spreadsheet recalculates. Any id...

Automatic Data sorting/ analysis in Excel

I have data in the form of four columns. The first three columns represent time, value1, value 2. The fourth column is binary, all 0's or 1's. Is there a way to tell excel to delete time, value1 and value 2, when the corresponding binary value in column four is 0? I know this is a lot easier in C++ or matlab, but for reasons beyond my c...

How can I perform a web query in C# similar to the Data > Import External Data > New Web Query in Microsoft Excel?

I need to pull data from a table on a website. I can easily do this in VBA using the Web Query, but I need to do this in C#. I'm just having some trouble figuring out how to properly convert the code. I got something close, but it's returning HTML with the data. I just want the data. Any help would be great. The block of code givin...