Questions tagged [vba]

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. Good questions on VBA generally contain some code and asks for solution of specific issues. Questions asking for entire solutions (please give me the code / how to do this and this with VBA) are off topic and will be closed as too broad.

Filter by
Sorted by
Tagged with
0 votes
1 answer
3k views

Update Word document with Excel VBA

I am trying to update a Word document using Excel VBA. Found this code at the link below but it is not working for me. It steps through the code but the Word document is not updated. At this ...
26 votes
1 answer
41k views

Which Excel objects are zero-based and which are one-based?

Using VBA to access the first sheet in a worksheet is Worksheets(1). The first item in a ListBox is myListBox.List(0). I heard that Collections are 1-based but I don't know what they are. VBA arrays ...
3 votes
1 answer
4k views

How to have a cell calculate only once

I have cell N29 calculating some values based on streaming data. Once a condition is met in cell Q29, the calculation or final value should be passed to cell O29 and no longer calculate in either cell....
0 votes
0 answers
13 views

Unique ID for Fields and Cross References in Microsoft Word

I am working with a collaborative Microsoft Word Document with Figures and Tables cross referenced throughout the document. For instance, there are 75 figures linked with Captions. We have cross ...
0 votes
0 answers
25 views

Mentions affecting Regex Validation

I was wondering if anyone came across the issue with Regex validation in Microsoft Outlook when including mentions (i.e.,@Tony or @Jodie). The below code works fine when there is no mentions in the ...
2 votes
1 answer
14k views

Print Serial Number or Incrementing Number in Word Document Footer

I feel this is likely a dup, but I can't find good answers and "Question's that may already have your answer" only shows an answer for excel. I'm looking to track documents printed by having a serial ...
0 votes
1 answer
106 views

Excel Macro Code Disappearing in Network Trusted Location

This problem -may- have started around when I switched from Office 2019 to 365, however I've been doing so much upgrades lately (windows 11, server 2022, etc) that my memory is foggy. Over the past 6 ...
0 votes
1 answer
2k views

VBA EXCEL: find method not working when looping through each cell in selection

I'm trying create a macro that, after a range selection, will tell me how many 20ft or 40ft containers where found in the sample. The macro basically looks for the string "1x20" or "1x40" and when ...
2 votes
2 answers
2k views

Excel Outlook VBA Save Unread Emails to a Network Folder

I was able to build an Outlook VBA script in Excel that would save down the just the attachments of "Unread" messages in a specific Outlook subfolder to a folder on my network and then mark the ...
0 votes
1 answer
43 views

IN VBA, How to sum hours and minutes exceeding 24 in memory (not in ranges of excel)

I'm getting some data in the format of text(like for example "12:47" that means 12 hours and 47 minutes) from a URL document and calculating some parameters like overtime work, shortages and ...
0 votes
1 answer
5k views

Open an Access database with scripting disabled (macros and VBA)

Suppose you want to examine the contents of an untrusted Access database. It seems there should be a way to open it in Access with macros and VBA disabled. Searching around the web, I've found ...
0 votes
1 answer
4k views

Excel: Find a specific cell and paste the value from a control cell into it

I have two columns one containing the room number, e.g. B-CL102, the other containing a varying integer. I want to enter a different, manually determined, integer in a third column. Whether by macro ...
0 votes
0 answers
13 views

Inserting Today's Date In A Cell If Other Cell Values Are Changed or Added using VBA

So I have this spreadsheet that I share with my Team, and I'm looking for a way to have a Today's date put in a cell, everytime there's a change in the worksheet. I found this coding, which is working,...
0 votes
1 answer
4k views

Excel VBA save to CVS file

I have an excel file which has a macro which saves the file as a .CSV file. I have a program that calls on the CSV file but the program only recognizes the .CSV file if I open it manually and save it. ...
0 votes
1 answer
5k views

VBA to capture output, a number, from shell command

The following batch command generates a number, the count of the number of files whose size is greater than a threashold, 512K in this case, although the count is off by 1. forfiles /P C:\ /M *.* /S /...
2 votes
2 answers
10k views

VBA: How to replace entire Excel cell value basing on its content?

I have an Excel Spreadsheet with some names in a cells. There can be as one name per cell as multiple names in one cell. For example: Cell A5 contains "Joe", cell BD54 contains "Joe;Harry;Molly", ...
0 votes
0 answers
14 views

Automatic change of keyboard language in a worksheet in Microsoft Excel

In Microsoft Excel, and using visual basic, how to set a default language for different columns? For example, columns A & C should be set to English by default and columns B & D to Persian. ...
0 votes
0 answers
71 views

VBA Excel Multiple files saved in newly created folder named with text in cells range and date

I am trying to create a folder and save as copy of my workbook in this folder for all the filled cells in range B11-B14 of my workbook. I managed to create the folder and the file with the correct ...
1 vote
3 answers
6k views

Find Related Messages in Outlook 2010 with New/Popup Window like in 2007

In Outlook 2007, to help clear the inbox, finding related messages would open a new small window that would allow to open the messages or to move them into folders easily, then go back and do the same ...
2 votes
1 answer
81 views

Excel VBA Else Without If Error -- I can't seem to find where the error is?

I am configuring a long IF statement, where if the financial period is the same, it merges the cells together under the same period header, and if not, it creates a new header with the new period name....
0 votes
2 answers
4k views

How to VBA update a cell value based on another cell

I've looked all over stack exchange and have not seen exactly what I'm looking for. I have an extensive list of some items that need constant calibration at different dates and intervals, and what I'm ...
0 votes
3 answers
6k views

Excel "Can't find Project or Libary" - but which one?

Using Office 2016. I have an Excel file with VBA. Whenever I open it, I get the error "Can't find Project or Library". Excel immediatlely closes. I opened Excel and, without opening the file, looked ...
0 votes
0 answers
40 views

Filtering a Table based on a Cell Reference in another workbook, then copying it

I am trying to filter a table based on a cell in another workbook, the reference for the filter would be in workbook "ReportWB" and the "Project Summary Detail" sheet, cell "...
1 vote
0 answers
44 views

How to run a Word macro from the command line?

I'm trying to save and close all open Word files (to start I only target one of them). The macro I made works when ran from Word (clicking "Execute"), but it won't run when called from the ...
2 votes
3 answers
5k views

How to make nested loop faster to find instr in vba

Problem Description: Loop through excel max rows(approx. 10000000) to find instr. After finding instr, taking the values and copy the values to different sheet. Every time find the match which is ...
1 vote
2 answers
95 views

Excel, update cells when clicking on another cell

I have tried a few different bits of VBA found here on SuperUser but not able to get it to work. I am trying to update a cell when I just click on another cell. I have data in A43:A54, it's a list of ...
0 votes
0 answers
59 views

Excel VBA: Export/save won’t work correctly

(Hope the formatting is okay. I’m doing this on my phone, so it’s hard to tell.) So, I’m trying to create some VBA to automate the clean up process of data I get from my field crews. Everything below ...
2 votes
1 answer
4k views

How can I use a macro to group and average the values in an Excel column?

I'm new here and I've been struggling with macro writing. I was wondering if anyone could help me out with making/explaining a macro that could be used in my data set. I have an Excel file that looks ...
1 vote
1 answer
1k views

How do you renumber sheets in a large Excel workbook?

With an Excel workbook with a number of sheets in a workbook, it can be difficult to rename the sheets manually if you insert or delete a sheet: Intro-A <<== Skip this one, please Intro-B &...
0 votes
1 answer
6k views

Make sure Excel file cannot be saved if the column has empty cells

I want to enforce entering the values in a certain column, up to the point where there are values in an adjacent left column A. It would be ideal to avoid popups but instead, have the cell borders ...
1 vote
1 answer
2k views

Excel VBA code and Outlook Programmatic Access warning

Since about last Friday one of my Excel macros that generates an email has been getting this warning: Microsoft Outlook A program is trying to access e-mail address information stored in Outlook. If ...
0 votes
0 answers
51 views

Linking columns on different sheets

I'm very new to VBA coding (only dabbling for this specific project), so I would really appreciate any advice on an issue I'm having. I'm attempting to link a column range (A2:A300) on Sheet1 to a ...
0 votes
1 answer
62 views

Replace with wildcards in Excel or batch edit some wrapping formula

I'm only trying to delete some CONCATENATE() function from some formulas in Excel. What I have; here 'Something' could be a lot of things (digits, <, >, texts, etc… CONCATENATE("Something = ...
0 votes
3 answers
8k views

Running VBA on a shared mailbox Outlook 365

I have this code for saving attachments from e-mails with a specific sender and topic, down to my hard drive. It works fine when it is only working on my personal mailbox. But i need it to work with ...
0 votes
0 answers
24 views

extract VBA userform from corrupted word docm

I have a userform in word built over 10+ years. Today Word chose to crash the normal.docm file and the VBA project became unreadable. I have used python scripts to extract the code, but I don't have ...
0 votes
2 answers
5k views

How to modify these VBA codes to save excel sheet in excel format (.xlsx)?

I have added a button in excel sheet and now when I click that button it saves the sheet at specific path with specific name but in pdf format. I want to save this sheet simply in excel format (....
1 vote
1 answer
4k views

Expand or minimize worksheet groups on Excel's tab bar

Is there a way to group worksheets in Excel 2010 so that not all tabs are immediately visible? Basically, so that they could be expanded and minimized as needed. I have a few Excel workbooks with ...
0 votes
0 answers
60 views

Highlighting duplicates in Excel with VBA, multiple sheets

I have a workbook set up with a sheet for every month and then a summary sheet, so 13 sheets total. Each sheet, other than my summary page, have two sets of tables set up. A table for each week in ...
1 vote
1 answer
62 views

Macro for using Goal Seek over a range of cells

I'm trying to automate the GoalSeek function over a range of cells. Each cell in Columns I and J calculates a quantity of interest using two different methods, and the results must agree. Each cell in ...
4 votes
1 answer
3k views

Delete the digital signature from a received Outlook message

My goal is to delete the digital signature in an Outlook message. My initial idea was to create a VBA script (which I have done below) to enumerate all attachments in the selected mail item and ...
-1 votes
1 answer
202 views

VBA Code to hide rows on multiple sheets

Very new to this so. Is there any way to have the option cell K473 be on tab 1 and change the hidden rows on tabs 2 to 11? The below works perfectly on a single sheet, but would like to have the ...
0 votes
1 answer
4k views

Copying Excel sheets from a another workbook

I try to copy sheets from another workbook, but the problem that I want to start copying sheets from a certain sheet that I know the name. I tried to adapt several codes that copy all sheets but I ...
1 vote
1 answer
5k views

VBA Function or Macro to Move Selected Message(s) to Folder of Conversation

I organize all my Outlook messages as conversations. I'm looking for a function to move the currently selected message(s) from the inbox to their respective folders. For example, if I have an email ...
0 votes
1 answer
203 views

Any way to allow multiple people to edit a coauthored, password protected workbook, at the same time?

I am currently working on a sheet that I want select people to have full access to, while everyone else without the password for the sheet cannot. I can do mediocre and overly complicated solutions ...
0 votes
1 answer
90 views

VBA - Copy Visible cells not selecting everything

I have a very long macro that I've written that looks at a report sheet, breaks it down by many different criteria (putting some of the results on different sheets), and does hundreds of calculations. ...
10 votes
4 answers
4k views

How to change Control-Y behavior in Excel-VBA's IDE

Excel VBA's IDE registers a Control-y as "cut this line of code". By contrast, redo-ing is accomplished by Alt-e, R. Is there any way to change this behavior and make Control-y be the much more ...
0 votes
3 answers
371 views

Update macro to expand each row height by X pixels

This works fine to set all rows to 25 pixels. Sub sbChangeRowHeightMulti() Rows("3:1000").RowHeight = 25 End Sub But I want to take the existing row height and add 10 to it. So something like this ...
5 votes
4 answers
18k views

How can I insert the quoted price of gold from kitco.com into my excel spreadsheet?

kitco.com provides a realtime price quote for gold and other metals. I have a spreadsheet which makes calculations based on the price of gold and would like for this realtime value to automatically be ...
1 vote
1 answer
4k views

Cannot use Date and Time Picker in Office 2013

Since few days I have tried to apply this ActiveX to my Excel 2013. I made small app for running reports in Excel and I need some way to pick start and end date. Easiest way to do it was Date And ...
0 votes
1 answer
59 views

Hidden Personal Macro Workbook Opens upon running macro to close ActiveWorkbook

I have a macro that I have coded to close the activeworkbook after running a series of formatting and saving it as a PDF. However, it opens a hidden version of the personal macro workbook immediately ...

1
2 3 4 5
75