vba

access report from dynamic crosstab query and vba to "manually" generate reports

I have come across the problem of generating complex access reports (by complex I mean with data processing, variable number of fields, among others). Let me explain in deeper detail some of the things I need to implement: Some fields should not show according to some values in a query If a certain record does not exist, a nice colo...

What are pros & cons of Passed Arrays vs Global Arrays in Excel VBA

Ok, 2nd attempt at writing a Stack Overflow Question, so forgive me if this seems familiar. I am rewriting an Excel Macro that was built over a 2 1/2 year period, frankenstein style (added to piecemeal). One of the things I need to do is load the data into an array once and only once for data accuracy and speed. For my skill level I...

Can I ReDim a module level array using a property?

I think I have a pretty good handle on how to handle module level arrays in VBA though Property Get and Let. Is there a way to ReDim a module level array through a property? The following code errors out at the ReDim statement in the last procedure (DoTest). Private mstrTestArray() As String Private Sub Class_Initialize() ReDim ms...

how do I use a excel function inside the vba editor

I want to write a Excel function like this. It is an extension of the Dec2Bin function Public Function Dec2BinEx(x As Long) Dec2BinEx = dec2bin(x) + 10 End Function But I am getting an error when trying to use it. How do I call a excel function inside the visual basic editor ...

Merge contents of 2 Excel cells keeping character format intact (using VBA)

As the title says: I try to merge the contents of 2 cells into a 3rd in Excel. There was a similar question here on SO, but those solutions do not keep the character format intact. For example, parts of the source cell contents are formatted bold and red, other parts are normal. When I merge them like Range("A3") = Range("A1") & Range(...

Excel formatting cells

I have a sheet which has date with extra space at end. And i want to remove them so that i can format them as date and sort excel sheet. I used macros available online for ex: Sub TrimColumnA() Dim rng As Range On Error Resume Next ''#if entire column is blank, exit sub Set rng = Intersect(Range("B1").EntireColumn, ActiveSheet.Use...

Excel 2007 VBA signed certificate

Is it possible to create a certificate for an Excel workbook which has some VBA macros, and distribute the certificates to a small group of users? ...

How to assign certificates to excel macros programmatically

Hi, I have developed some code which creates excel macros and each time after creation of new macro I want to digitally sign the macro programmatically. Can you let me know if there is any way using which I can create new digital certificates and assign those to macro programmatically. Thanks. ...

Tuple style object in VBA

I'm using VBA in an Access application and I would like to have a n-tuple object that contains values of different data types. Then I would like a collection of those objects. If I was doing this in javascript it would look like: var myStructure = { name: "blah" age: 33 moreStuff : "test" }; And then I would need a collectio...

Excel VBA Dialog box with custom buttons

I would like to create a dialog box or message box in excel WITH custom button labels i.e. FIRST and SECOND. I would like for this box to open up when the file is first opened...and doesn't allow user access to the worksheet until they select either FIRST or SECOND. I can make a form, but I would rather not add a form since this should...

MsgBox function default fourth button

I noticed in VBA that the MsgBox function has a allowable constant of vbDefaultButton4 which will make the fourth button the default. BUT of all the allowable constants for buttons, none give you four buttons. Is there a way to get a fourth button on a MsgBox, or is this useless, or something else? ...

Get the current cell in Excel VB

I have a small script in Excel/VB that I'm trying to get working. All I want to do is select a dynamic range of data to copy but I can't seem to find any help/code on how to get the grid data (like A11). Here is code I have from macro recording that selects the range of data: Range("D291:D380").Select I was hoping I could just do ...

VBA How do you copy and paste in a Userform using right-click?

I want to allow users to be able to paste values into TextBoxes in a userForm in VBA. You can use Ctrl-v just fine, but not everyone knows how to do that. How do I enable copy and pasting using a right-click menu? ...

Excel VBA Macro: create a chart from CSV?

I have a CSV file with three columns (A,B,C). I can record a Macro which selects Col A + Col B, then inserts a chart of A versus B. This works, but the code generated contains a hardcoded ref to the 'Sheet1' like this: ... ActiveChart.SetSourceData Source:=Range( _ "'Sheet1'!$A:$A,'Sheet1'!$B:$B,'Sheet1'!$A:$A,'Sheet1'!$B:$B")...

Converting all elements of an array from string to double at once VBA

Is there a way to convert all elements of an array from string to double without having to convert each element one by one. I want to avoid to use a loop if possible. I'd like to know that for VBA not VB.Net ...

Outlook VBA: How to get started - need to save attachment from current email to a derived folder.

I'm looking for a starting point here, so no code to post I'm afraid ! I would like (if possible) to be able to open an email in Outlook (in the normal way, from the front-end), and then click a button to run a macro, which will extract the attachments from this email and save them to a directory path (derived from the subject). Sound ...

Word VBA checkboxes with link to image that needs to be built up

Hi, I am having problems with a table containing checkboxes in Word. I am working with a table containing 10 checkboxes. Next to this table, there is an image. When the user checks one of the checkboxes, something has to be added to the image, i.e. the image is further completed. However, the order of checking the checkboxes is not fix...

Error returning object instance from function in VBA

I'm trying to instantiate an object and return it from a function. The class I'm working with is one that I've created. However when I try to set an Object to what was returned from the function I get an error. What am I doing wrong? Function CreateBlah(NAME As String, Count As Integer, val As String) As Blah Dim b As Blah Set b...

Outlook VBA Macro: Best way to indicate 'please wait'...

What's the best practice for indicating to the user that a Macro is running within Outlook ? The macro can take around 1-30 seconds to complete. I want to avoid a modal 'msgbox' popping up before the macro is run, as this can be annoying. I would rather avoid the hourglass cursor if possible, and wondered if there was a better way. Is...

Secure data type to store password in a VBA.NET forms app in Systems.Setting

Need to store the username and password for an outside application inside of a windows forms vb.net app. For initial testing, I just set the settings type to "Text", but want more security. There are System.Security and Encryption types available, but not sure where to begin. Any suggestions on how to Add, Update, and Delete the values...