Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
158 views

Change loop to write results in additional cells

I have been using the following code for awhile but need some help in making one change. I’ve tried and tried but it won’t work. If someone could kindly take a look, my research says I’m looking for a ...
0
votes
1answer
49 views

Outlook categories count for Shared Mailbox

I am trying to get the count of the number of items associated with a category on a Shared Mailbox that is linked to my Outlook account. All code that i have found only references the actual Outlook ...
0
votes
0answers
52 views

How to write a write-protected file with VBA

I have a little VBA project (in Powerpoint) in which I need to create and save a write-protected file (of any kind, the initial thought is a txt file). What is the best approach for that? I can ...
1
vote
1answer
57 views

Work Sheet Change

I am trying to put together a macro that will put in a time stamp. I have 2 sheets input and dashboard When cell A2 on input changes I want a the function NOW to be used on cell M8 on dashboard I ...
0
votes
0answers
44 views

Creating a macro in excel that pauses at the stage I run VBA code

I am creating a macro in excel. I get to a particular stage in the automation when I need to run some VBA code. During the automation process, I click on Developer and input the things that I need ...
0
votes
1answer
31 views

prevent running multiple instanes of a macro

"how to avoid Running Multiple instances of macro" Sub CallBot() If Activesheet.Range("A1").Value = 1 Then Call Bot ElseIf Activesheet.Range("B1").Value = 1 Then Call BotTwo ...
0
votes
0answers
92 views

Excel re-apply filter when data changes in another sheet

I have a workbook with 2 sheets. The first sheet includes a daily work log and a note on whether or not each item is complete. I call this the "Log" sheet. E.g.: Then I have another sheet, which I ...
2
votes
0answers
137 views

Updating List in Sharepoint Online (o365) via Excel/VBA

I am currently using VBA to update/create new sharepoint list items via SOAP. My IT dept has advised that they are migrating to SharePoint Online and the same code no longer works, I believe due to ...
0
votes
1answer
97 views

Excel VBA syntax error

I am trying to use the following code I found on the web but it stops due to a syntax error:see below Sub TestCNR() Cnr 10, 4 End Sub Sub Cnr(n, r) i = 1 For j = 1 To r Cells(i, j)...
0
votes
0answers
30 views

Runtime error '9' Subcript out of range

Kept getting runtime error '9' subscript out of range and the codes in ** ** gets highlighted. My worksheet name is Payroll. Please help!! Private Sub Search_Click() Dim lastrow As Long Dim ...
0
votes
1answer
19 views

Adding a space between the value and unity inside a equation in Word using Visual Basic

This is the point. I have a document that was imported from Pages that contains a lot of equations. The equations have things that were written with a space between the number and the unit, like: ...
0
votes
0answers
20 views

How to add a ComboBox in Word that allows free typing and multiple choice selection?

I am working on a document where I need to include a ActiveX ComboBox which would allow the user to choose multiple items from the list or add free text. What I am currently having difficulty with ...
1
vote
0answers
16 views

Excel filter vanishes after change in sheet

I have a excel-file with multiple sheets. Sheet1 (Lagerliste) holds a bunch of logistics-data. Mainly: WHAT is WHERE In a seperate sheet I want to filter all lines containing a certain value (...
0
votes
0answers
25 views

Excel macro works (except) for one cell

I have a macro that is currently working but not 100% and was wondering if someone could kindly review it. The issue is when a number is entered in cell H24 the macro does not do the calculation like ...
0
votes
2answers
93 views

count cells based on value if consecutive values same and more than 6 cells

In Microsoft Excel 2013, I need to count the number of cells in a row that contain the number 8 and are also part of a sequence of at least 6 consecutive cells containing 8 (ignore if the value is ...
0
votes
1answer
281 views

Excel VBA Runtime error 1004 Application-defined or object-defined error

Upon clicking run, I kept getting the runtime error 1004 and the codes in brackets below gets highlighted. Any one can help me with this Private Sub Add_Click() Sheet4.Activate (Range("A1").End(...
0
votes
1answer
50 views

Data is not copied in the same row (multiple workbooks to master sheet)

I have a VBA routine to copy selected cells from multiple workbooks to one master file. But it has the problem that, there are possibilities that one or more of the source (input) workbooks will ...
0
votes
1answer
13 views

Word Macro: Read number as a word rather than separate characters

I a teacher and am creating a macro to look for common errors in my students' papers. For example, I build a macro to look for the word "profit". If it is found, it then looks at the previous word. ...
0
votes
0answers
26 views

Runtime error 1004: application defined or object defined error

The error is on Wdest.Cells(dcodecount,4).Value = dloc I don't understand why it does not work. Can someone help me with an explanation why it does not work? Thank you Sub Filterdtag() Dim address ...
0
votes
0answers
43 views

Write Dates into array / Stop loop when reaching empty cell / Excel VBA

I am fairly new/coming back to VBA after ~10 years of Hiatus. Now I am faced with the below Problem: I would like to write Dates from a column in worksheet1 (say Colum B) into an Array until I reach ...
0
votes
1answer
42 views

How to reference a shape by name and what else can be used in .Select?

I use MS Excel 2007 My question is in two parts I have a form option button called "Option1" How do I refer to that button in other macros? I know that I can select it using: ActiveSheet.Shapes("...
0
votes
0answers
14 views

Convert tracked changes to highlighted (continued)

is there a line we could add to the following VBA routine in order to highlight one letter before and one letter after all deleted text, so that when all changes are accepted, we can still visualize ...
0
votes
2answers
111 views

Tell a macro to check if object exists and if yes do A. but if no then do B.?

I use MS Excel 2007. I have the following code in a macro that creates two Option Buttons (not active X) into Cell B25. Range("B25").Select ActiveSheet.OptionButtons.Add(129.75, 540, 24, 20.25)....
0
votes
0answers
42 views

Fixing AS400 error: “Someone else is working in 'J:\AS400 Automation\tk.csv' right now. Please try again later.”

I was able to create a simple command in AS400 by recording some macros from AS400 then adding some codes thru the .ebs file. It was working fine when I was using it but when it was applied to 10 ...
1
vote
0answers
13 views

VBA to check which stylesheet is loaded in Word

I have a small macro to change styles automatically, but it won't work unless the right style sheet is selected. At the moment, it looks like this: ActiveDocument.ApplyQuickStyleSet2 ("Anthology") '...
0
votes
1answer
59 views

Macro/VBA Code to List and print names and code of all macros in a workbook

I am using Excel 2007 For this question the name of my workbook is PrintCode.xlsm Is there a Macro or VBA Code that will print all of the macro names and code within the open workbook? I have found ...
0
votes
1answer
41 views

Exactly position new option button in VBA

Is there a way of exactly positioning and sizing a new option button in VBA or a macro? The code I am using inserts a new Option button in which ever cell is currently selected within a worksheet. ...
0
votes
1answer
70 views

Add dynamic comments to Excel cells via VBA

I am trying to use comments to show the current due date of a Task via a VBA Macro. My current solution looks like so: Sub AddDueDates() Dim strPrefix As String strPrefix = "" With Range("Target")...
0
votes
1answer
57 views

Excel — Comparing 2 lists with several columns

I have 2 lists with several columns. Each list has 5 columns, and 4/5 columns will have different values from both lists, but the remaining column is for dates. Both lists' 'Dates' Column are of ...
0
votes
1answer
220 views

Excel VBA - Copy cell values *without* data validation

I'm having a wee issue copying cells from one Worksheet to another in Excel VBA. The Source Sheet contains an individual client record stored in a single row. The Destination Sheet is a collection of ...
1
vote
0answers
14 views

Separate old files with date information stored in excel

I have approximately 2000 files, of which I need to separate any files before a specific date (say, 2015). These are currently separated into subfolders for each categories of file (Say, projecttype1,...
0
votes
0answers
30 views

Tips to speed up code which copy/ pastes pictures?

This is my first project using VBA. I have a code (see below) that reads if a number on the sheet is present. If it is, then the code will call a macro to copy the source picture from another sheet, ...
0
votes
0answers
102 views

CommandBars.ExecuteMso - VBA code not working

I am trying to make a macro to pull up the 'Change Picture' file explorer. Basically I just want a macro that will do the same as right clicking on a selected picture and then clicking this: I don't ...
0
votes
0answers
35 views

ExecuteMso - Change Picture > From a File

I would like to create a button that would bring up the change picture feature in excel. I want the users to be able to click the button above the pictures to change the pictures when needed. Can ...
0
votes
0answers
34 views

Using stored numbers in a formula?

Here's the piece of code that's giving me trouble: Dim lastRow As Long With Worksheets("Rent Roll") lastRow = Worksheets("Summary").Range("NUM_UNITS").Value .Range("A1:A" & lastRow + 25)....
0
votes
2answers
33 views

VBA Code to Hide Rows in a Table (More complicated than it sounds)

LAST POST WAS DELETED - "BEEN ASKED BEFORE" - PLEASE READ WHOLE THING :) Basically I have a large table (500 rows) and I need to only show the amount of rows based on the value in a certain cell (If ...
-2
votes
1answer
39 views

How to increment a list of values with a button

I am trying to manage a list of students in an excel database. I am trying to create a button that will increment the semester column by 1 when clicked. I have tried using an active-x button and a ...
0
votes
0answers
16 views

How can I protect my Excel workbook by a password for unauthorized device access using VBA?

I only want to give access to 5 devices based on their PC username and it should not ask for password for authorised devices. For others it should ask for password before opening the file.
0
votes
0answers
57 views

Moving filtered data into variant variable array

I am currently trying to automate a manual task. I have filtered my data and this works fine if I copy and paste the visible range into another sheet. I am trying to write the visible data into a ...
1
vote
0answers
55 views

Msgbox VBA on closed workbook

I have 2 different workbooks: workbook-1 workbook-2 I want msgbox in workbook-1 referring to values in workbook-2. For example: In workbook-1: | A | | B | | C | In workbook-2: | A | 10 | 5 | 6 ...
0
votes
1answer
73 views

Excel 365 VBA macro

i'd like to populate a spreadsheet Nr 1 based on the entries I made in a different spreadsheet. Here's a description of my workflow: Based on a due date, I generate a calenderweek for specific Task ...
0
votes
1answer
24 views

Making a cell mandatory based on conditional formatting of other cells part 2

I am looking to achieve the following: Column C has been conditionally formatted based on data entry that if data is out of range, cell background will turn red. I am wanting to force data entry at ...
1
vote
0answers
32 views

Making a cell Mandatory based on conditional formatting of another cell

I am looking to achieve the following: Column C has been conditionally formatted based on data entry: if the entered data is out of range, cell background will turn red. I want to force a data entry ...
1
vote
1answer
28 views

Creation of a Folder Structure with a path defined in a cell (or pop-up)

I'm a new to using excel's VBA and was wondering if you could help me figure out a solution. So I'm seeking to create an excel spreadsheet that will create a folder structure in a certain location. ...
-1
votes
1answer
153 views

VBA code to protect sheets and show/hide buttons

I have a simple VBA code running every time my Excel file opens, and it worked fine for years. Since several weeks tho it stopped working. The purpose is for specific cells on every sheets to be ...
0
votes
1answer
107 views

Make a small change in my code

I have been using the code below but would like help making 1 small change. I need to change finding the "15" in the following line of code:“Set Found = SearchCell.Find(What:=15, Lookat:=xlPart)” to ...
0
votes
2answers
229 views

Unlocking Edit Ranges In Excel Using VBA

I am using VBA to add information to my spreadsheet whenever data is entered into a different column. However, to do this, I unlock and lock the sheet as part of the vba script. This requires the ...
1
vote
1answer
63 views

Combine multiple worksheets into one sheet while excluding some worksheets

I have 5 people that each maintain their own Excel file. The files all have a tab that I care about with the same data structure (columns) and more 20,000 rows each. I need to pull that tab from each ...
2
votes
1answer
159 views

Change excel formula language using VBA

I need to be able to use english formula on my french laptop. Is it possible to use this without installing a language pack? I have seen this answer from Microsoft: https://answers.microsoft.com/en-...
0
votes
1answer
98 views

Save and rename an attachment from outlook 2013 to a specific folder

I have been using the steps from another post on this site and it worked for a few days and now it does not. The file always comes in from the same person and is always an xlsm attachment. I enabled ...