Visual Basic for Applications; a subset of Visual Basic used in all Microsoft Office applications. Consider using this tag together with the tag for the specific application in question.

learn more… | top users | synonyms

0
votes
2answers
9k views

How can I find out which parts of an Excel workbook are the biggest in size?

I have an Excel .xlsx that weights 47MB. I'd like to know which parts of the workbook are the heaviest and work them, since I haven't made much progress manually trying to identify and reduce the ...
0
votes
1answer
133 views

Removes rows (based on condition) and copy cells (based on condition)

I have to modify a huge VBA script, I am new to VBA and I must also say that I am not loving it :( I need some help writing an efficient For-loop, let me explain with an example. During the first ...
1
vote
3answers
385 views

Assign triggered code to multiple images - Excel VBA [duplicate]

I wanted to assign some specific actions when clicking on one of the images I have inserted in my Excel sheet. The problem is, I got 52 images (Poker cards for those wondering). So, my question is, is ...
0
votes
1answer
14k views

How to merge multiple sheets of Excel files to one Excel file?

I need to merge hundred Excel files into one Excel file. Each Excel file needs to be merged into its own worksheet in the workbook and the destination worksheet needs to have the name of the original ...
0
votes
1answer
153 views

Identify Image in Excel - VBA

I have an Excel sheet, and I want to create some macros using VBA. Specifically, I want to change an image with a predefined one, every time I press a button or every time I press on an image. ...
2
votes
1answer
705 views

Getting the index entries of a Word document in VBA

I have a collection of Word docx files in various subfolders. I need to create an index file with links back to the original files. I thought that VBA might be the easiest way to do this. I can find a ...
2
votes
2answers
3k views

Align secondary axis origin with primary

I am interested in aligning my secondary axis such that it lines up exactly with my primary axis. To be more clear, I want the origins to both line up at 0 at the same place, each preserving their ...
0
votes
0answers
462 views

How do I really enable events in Word VBA?

I've found the instructions to enable events, but this does not always work. When I create a new document from a template events are not enabled. I've got the class module to have word run with ...
1
vote
1answer
188 views

How do I access a new document in vba?

I made a .dot template with a few macros. However, when I create a new document based on the template I run into trouble. If I reference activedocument, I get the message that no document is open. So ...
-6
votes
1answer
377 views

VBA for “IF formula” with multiple results in a single cell [closed]

How can I convert this to VBA? Using this formula, it cover 6 rows only and the formula is already too long. My report has 600 rows. =IF(AND('Risk & Issue Log'!$K$2=$D5,'Risk & Issue ...
-1
votes
1answer
72 views

Format of Row in VBA based on 1stCell and also Compare to above row?

I was wondering how would i through VBA conditionally format the whole row or a row in a range based on the first cell in that row? Also it would require a comparison to the previous row to current ...
0
votes
1answer
25 views

Excel leaving formula when selecting another sheet

I am attempting to reference a range in another workbook in a vlookup. I type =vlookup(a1, and then go to the other workbook to select the range, but alas, I am no longer in the vlookup formula. I ...
0
votes
2answers
598 views

Are there events defined in the word vba object model for these events?

First of all, I did look and did not find any. I want a macro to run whenever one of the following happens: The document is opened The document is saved Text is pasted into the document The ...
1
vote
1answer
55 views

Searching the string in a text sitting on 1 coulmn

I'm very new into VBA coding, I would like to have some assistance as I have been trying for two days, I have got data fixed in column A, I would like to search for a string in that column, eg ...
4
votes
1answer
1k views

How do I replace all breaks in a selection in Word using VBA?

I've got a part of a document selected, and now I want to replace all manual page and section breaks (the latter of all types, such as next page even, next page uneven, next page, continuous, column) ...
0
votes
1answer
7k views

How do I select text between two “bookmarks” in Word VBA?

Note: Originally I asked how to select text from a certain point downward, but I've got a solution for that: Dim f As Word.Field For Each f In ActiveDocument.Fields If f.Type = wdFieldAddin And ...
0
votes
0answers
197 views

Macro for hiding table colums, in multipile files, and another on to reverse it

I know almost anything about VBA so I can't really code the Macro that I need for MS Word. I hope that I could get some help here. The basic functionality that I want is to take a Word document with ...
0
votes
1answer
353 views

Excel - How can I highlight duplicate cells in near-matching worksheets?

I'm running a March Madness bracket tournament using Excel spreadsheets. I have one sheet where I will input the actual winners. I have an additional sheet per participant that is near-identical, only ...
0
votes
1answer
55 views

New instance of Excel does not see already opened instance

I have Avizo.xlt with one Worksheet and a code which intended to put this WS inside already opened document, which is SLK report made by our ancient ERP system, and close this document. Everything ...
1
vote
1answer
162 views

How to remove “no cents” when spelling out cents less dollar figures in Excel?

Currently, I am spelling out dollar values using a module from the Microsoft support website. Here is the link http://support.microsoft.com/KB/213360 I am able to spell out dollar values in Excel ...
0
votes
1answer
100 views

Is this possible in Excel? (VBA)

I want to create a VBA macro that will do the following: The Excel file with the Macro should only open when the file is opened from a certain folder in the Windows directory. If it is not opened ...
0
votes
1answer
5k views

Show or hide rows in an excel sheet subject to the value of a particular cell (excel 2007 & Windows 7)

I have made a spreadsheet to specify decoration selections from a range of standard options. There are five separate ranges so this is the first selection then within each range there are additional ...
0
votes
1answer
2k views

How to Replace Words With VBScript Regex and VBA?

what is vbscript syntax for .net: \b[a-z]+\b Hi trying to replace all alpha words in the source. .net regex tester confirms this pattern will find all words: \b[a-z]+\b this: ...
0
votes
1answer
607 views

VBA Excel: Sub procedure to change caption in a UserForm control

I'm creating a user form that shows the value(numeric) of the last used cell in a column. I'm just guessing on how to do it but it doesn't work, this is what I got: Sub show() UserForm1.show ...
1
vote
2answers
10k views

Call PowerShell script from Excel macro

I'm trying to call a PowerShell script from a macro in Excel. I have seen a number of examples along the lines of: retval = Shell("powershell ""C:\MyTest.ps1""", 1) When I try to use this, ...
0
votes
1answer
249 views

Autoforward Outlook emails to external only under certain circumstances

Is there a modification that can be made to the VBA code provided in this response from an earlier post that would only forward email from a certain email address rather than forwarding everything? ...
0
votes
1answer
894 views

Can Excel's Find formula have multiple find_text criteria?

I have a list of names on a NAMES tab range A1:A100. On another tab 'Data Export', in column A I have an export of thousands of comments where one of those names from the NAME tab can be found within ...
-1
votes
1answer
614 views

How to combine several excel workbooks into a single book

I have several, multi-sheet workbooks which I would like to combine so that I can search them all simultaneously. So, the merged workbook will contain tabs 1,2,3, of the first workbook, then tabs ...
1
vote
1answer
8k views

VBA Excel: Function to find a string in another workbook

I'm trying to create a function that searches a string (bom) in two different workbooks and returns a value next to that string. I know the ranges in those workbooks where I want to perform the ...
1
vote
1answer
625 views

How to know which macro is assigned to a certain toolbar button in Word 2003

I have a Word 2003 toolbar made by someone else long time ago. The toolbar contains lots of buttons and assigned macros. Until now I have been able to set breakpoints in the VBA code in order to ...
0
votes
1answer
82 views

Adding two numbers using macros failed to execute

How to add 2 numbers using macros? I tried below but i am not able to execute. Sub auto_open() n1 = InputBox("enter fiest number") n2 = InputBox("Enter 2nd number") ...
0
votes
1answer
117 views

Passing an element name using a variable in VBA

I have a multi page element on a MS Access form and I am trying to use GetArgs to identify which page to open using the below code. Dim WrdArray() As String If Not IsNull(Me.OpenArgs) Then ...
0
votes
1answer
254 views

How to create a custom “Shapes” menu in Powerpoint

By the "Shapes Menu," I mean the menu that you get to from the ribbon by going to Home -> Shapes. I would like to either: Choose my own shapes for within the Shapes menu, including changing the ...
0
votes
1answer
1k views

VBA Excel: How to select only numeric values in a range?

I used Range.Find to locate a string called "Qty", now I want to select all the numbers in that column. I would use .End(xlDown) to get the last row, however the last used cell in that column is not ...
0
votes
3answers
409 views

Excel: Classifiying data based on a bin system

I'm working with excel 2010 on windows, am a novice excel user but I can program, so you are welcome to throw VBA at me. I have a series of cells where a user can enter a number and another cell needs ...
1
vote
1answer
227 views

VBA Excel: Error during range selection during workbooks iteration

I have several files in one folder with the column "Part Number" but not all of them are in the same column number. The list doesn't necessarily start in the same row either. So I first look for the ...
1
vote
1answer
667 views

Excel 2010 VBA only affecting last row in range

I have some VBA code written in Excel 2010 to force padding around the rows in a table, but part of the code only affects the last row in the range. Here's the full code: Private Sub ...
1
vote
0answers
135 views

From outlook RSS: Download attachment, rename the file and save it to a folder

I know that it should be possible but can someone give me a script to do this? At least some hints how to do it is appreciated.
2
votes
5answers
565 views

Extracting Characters from Folder Path in Excel

I have a huge list of folder paths as text in an Excel worksheet from which I would like to extract the number after each backslash. These numbers then need compiling into a shortened reference. For ...
0
votes
1answer
2k views

Deleting entire row in excel if missing data in certain column or columns?

I just downloaded a Micosoft CSV file from Google Contacts and I would like to modify it so that I can organize the contacts in my phone. I am going back to my "dumb" phone as part of an experiment of ...
0
votes
1answer
18k views

Excel vba code for adding a value to existing cell of sheet

i have this code to add value of a cell to existing value of other cell which is below Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not (Intersect(Target, Range("E3")) Is Nothing) ...
0
votes
2answers
941 views

Excel 2010 formula, How do I write this formula? (VBA)

I need a bit of help from the more experienced Excel VBA users. Basically I have 2 groups of 3 cells (6 cells total) If one group of 3 cells is filled in it needs to accept it and not return a ...
1
vote
1answer
582 views

Excel 2007 VBA code to aggregate data based on conditions and calculate a weighted average

I am importing data from a trading system that has buy and sell orders for multiple securities(stocks). I need to aggregate the same security buy orders and the same security sell orders, creating a ...
1
vote
1answer
18k views

Split Excel worksheet into multiple worksheets based on a column with VBA

Question is simple and may be repetitive. I have an Excel workbook which contains around 50 columns I have a criteria column for splitting this workbook into mulitple workbooks The approach is as ...
0
votes
1answer
159 views

How to call a namer range using a variable to define the name

According the documentation, any quoted text names can be defined by a variable If I define Set xlsDataSource = Application.Workbooks("New_TOR_V1.xlsm").Names("MyRange").RefersToRange it works as ...
0
votes
1answer
31 views

Format a document using styles with macro

I have a document where I have created some styles. The content in this document is manually tagged. That is, where Heading 1 is to be applied it is tagged as H1 and the same way for Heading 2, ...
1
vote
2answers
4k views

Workbook doesn't find macro

I created a macro in a workbook which is being used by several persons on their own computers. For some of them, it seems to work fine, but for other a message appears that it can't find the macro on ...
0
votes
1answer
1k views

VBA string search within files in directory not working in Excel 2007

I'm trying to look for a string within a folder containing several files. Once the string is found it should select and copy a value in an adjacent cell 5 columns to the right(Offset(0,5)), then paste ...
0
votes
0answers
159 views

Reformat a text file using a macro in Excel

I need to reformat a report I receive every month as a text file so I can perform spend analysis on the data in Excel. The report was in a statement format before converted to a text file because the ...
0
votes
1answer
986 views

Outlook 2010 Run Script via Rules

I have the following subroutine in ThisOutlookSession: Sub receiveMtgRequest(Item As Outlook.MailItem) MsgBox "You have received a meeting request: " & Item.Subject End Sub I have set it to run ...