vba

Put Excel-VBA code in module or sheet?

What is good practice and good code hygiene? Putting code in Modules or Sheets? I have this Excel Workbook, with user interfaces in each sheet. Each sheet within the workbook does a different part of some overall task. Should I place the code relevant to each sheet inside the Sheet objects, or in Modules? Group into one module, or separ...

VBA Regex issue

Hey guys, has VBA any good mechanism for checking, if the content of a given Excel Cell matches a specific regex? In my case i want to know, if some cell has the format m m2 m1234 In fact, there's just one defined letter at the beginning, followed by a not specified amount of numbers. How do I put this into an If-Else construct? I...

Can I simultaneously declare and assign a variable in VBA?

I'm new to VBA and want to know if I can convert the following declaration and assignment into one line: Dim clientToTest As String clientToTest = clientsToTest(i) or Dim clientString As Variant clientString = Split(clientToTest) ...

Why does this regular expression match?

I have this regex: (?<!Sub ).*\(.*\) And I'd like it to match this: MsgBox ("The total run time to fix AREA and TD fields is: " & =imeElapsed & " minutes.") But not this: Sub ChangeAreaTD() But somehow I still match the one that starts with Sub... does anyone have any idea why? I thought I'd be excluding "Sub " by doing (?<!Sub ...

Sending formatted Lotus Notes rich text email from Excel VBA

While trying to use the hints in your answer at http://stackoverflow.com/questions/686384/sending-formatted-lotus-notes-rich-text-email-from-excel-vba I could do almost everything I needed: write multiple lines with data from a database of mine, formatting the body by mean of html code, with links and formatted text. I also need t...

VBA code:: seperate column into two parts but in each part still got ascending date

Hello, bascially, i have got a column consist of data that i want those starts with "EMUA-I" to be place at the front, with the ascending order of date. Then i want the "non EMUA-I" part to be placed at the back with the ascending order of date. please take a look at this reference file : http://www.speedyshare.com/files/23397356/1....

Mocking a method and returning different results

I've got a method that's mildly complicated and needs to be very well tested. Secret sauce stuff. Ok, maybe not that cool, but I'm not 100% sure how to go about getting these things setup. This sort of stems from my previous question here. I haven't used rhino mocks so I'm still bad/unaware of the syntax, so feel free to make a ton o...

Integration of VB6 inside ActiveX and Excel

My company has an ActiveX application used by more than 50000 customers paying customers. The data people need to input into the ActiveX application is coming from Excel (actually csv or XLS files, which they open in Excel). What we would like to do is to create functionality where the customer can input "=" in a textbox in the ActiveX c...

Referencing global variable - MS Access

Hi, Im trying to pass the name of a global variable to a sub routine and would like to know how to reference it. For example I could do the below with a control: Private Sub passCtrlName(ctlName as String) Me.Controls(ctlName) = "Whatever" End Sub Edit: For Example Public imGlobVar As String Public Sub passGlobVar(frm as Form, ctlN...

Return value indicating update success/failure of SQL Server stored procedure via ADO/VBA

I have a SQL Server 2008 stored procedure that updates values in a table. I would like to have the stored procedure return an integer value indicating that the update was successful (return 0) or not (returns error number). What would be the best way to accomplish this via ADO and VBA? Here some of my code in simplified form that perform...

VBA vs VSTO for excel to powerpoint

I'm currently considering a number of options for copying an excel sheet into a powerpoint presentation. Using VBA select a excel sheet, copy the range and place it into a newly created powerpoint slide as an image. I create excel automated html of a sheet, once that html is saved(initially), i create an image off of the html. Using VS...

Macro: how can I select multiple sheets in a workbook?

The workbook has over 50 worksheets and I'm working through an old macro that will help me amend the same range within each sheet. Howvere they have ahrdcoded the sheets.selectstatement. How do you write: Sheets(Array("Sheet1", "Bob", "1953", etc, etc, etc)).Select so that all the sheets are selected - from first to last, no matter what...

VBA for excel Question : How to make VBA search for multiple texts in ranges ?

Hello i want to make a form that have 2 or 3 text boxes that i can enter text values in it and vba search for this values if they are matched in 1 cell like if i enter "hello" in the first text box then i entered "world" in the other text box it search the hall collumn for a range that have "hello world" in it then copy paste it to anoth...

Interrupt/Abort a VBA-Loop

Hi Mates, I have a question on VBA on Excel: Is it (if yes, how) possible, to abort a long term loop? I have a Loop over several thousands of cells, which takes some minutes. How can I do a button or something like this to interrupt this loop manually? Building a button and overlay it with a makro is no problem ;-) Only the thing the m...

solution needed - 2 users running a program

Hi guys, So I've developed this Access 2007 application with about 2 forms, a lot of VBA code and a bunch of tables. Now the business wants to run this off a network drive (call it G:\ for example). My current solution (which I've already implemented is have a table similar to: __________________ |Setting | Value | =================...

What -- does in Excel?

Hey, Trying to decipher some Excel formulas and I see some stuff like SUMPRODUCT(--Left(...)...) What is the -- doing? Naturally seems like decrementing to me but couldn't find any documentation on it. Thanks. ...

Hide main form initially...Possible? (VB language)

Hi there, Is there a way to start a Windows Forms in (VB language) application with the main window not visible? Then later on when an external event occurs, I want to display the form. How can I accomplish this? Thanks. ...

Shade the last 3 days in color .. help!

Hello, I have got a range of date in one column, which i want to shade the last 3 days in blue and the rest in yellow. e.g. If the date is from 1/7/10 to 10/7/10, i want to shade the (entire) rows with date 8/7/10,9/7/10 and 10/7/10 in blue and the rest 1/7/10-7/7/10 in yellow. (Date in column K) I need VBA script to perform the job...

Excel VBA Copy multiple sheets into one sheet not working

I have the following vba: Data is all text, Rows A - J with column headers on every sheet are the same Data is sql queries all with "top 1000" 4 sheets (sheet1, sheet2, sheet3, Master) sheet 1: 100 rows sheet 2: 34 rows sheet 3: 900 rows Master: merged data from 3 sheets PROBLEM: Sheet3 only copies 84 rows specifically however addin...

dataset & featureclass

i want create a new feature dataset and then create a feature class into that.please help me about this. I could solve this problem.tanks alot for your answer. but i have another question.i work into gis whit vba.and i try to create a stream from a dem. i work whit Hydrologyop.i can create these streams into Geodatabase.But i want to cre...