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 ...

1
vote
0answers
12 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
11 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
71 views

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

In Microsoft Excel 2013, I need to count the number of cells across coloumns - but only if 6 consecutive cells have the same value (ignore if the value is in less than 6 consecutive cells). e.g. ...
0
votes
1answer
17 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
47 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
12 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
16 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
16 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 ...
-6
votes
0answers
29 views

Excel scripting dictionary

I would like to code for following data in "data" worksheet with vba scripting dictionary, with names as key and marks as values, also output dictionary data to "output" worksheet of same workbook. | ...
0
votes
0answers
13 views

Excel Code to find corresponding value to a cell [closed]

I would like to create a code in excel that allows me to look for all the corresponding values in other columns for the term that I type in. For instance, [the following image] shows a column of ...
0
votes
1answer
23 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
9 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
61 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
24 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
12 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
17 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 ...
-1
votes
0answers
13 views

Importing particular information from multiple word documents into excel

I need to scan hundreds of word documents and turn them into a database. The task is to have each word document into a row with the filename as the first column, then get excel to return a binary ...
0
votes
1answer
18 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
20 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
49 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
15 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
13 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
33 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
24 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
30 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
34 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
13 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
52 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
42 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
57 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
21 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
29 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 ...
0
votes
0answers
15 views

Move one column to another sheet's first empty column VBA code?

I am new to this macro thing. I've been trying to write the VBA code for the purpose of moving column E of Sheet1 to Sheet2's first empty column with the following code. If I can succeed I will ...
1
vote
1answer
22 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
0answers
45 views

Probably easy… Compile Error: Syntax error in excel macro

I know enough to know that red usually isn't good. I keep getting the compile error: syntax error when I go to run this macro. Any pointers? Thanks so much in advance.
-1
votes
1answer
69 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
102 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
42 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
30 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
38 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
38 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 ...
0
votes
1answer
20 views

How to set auto sort on two columns when open the workbook?

I have a workbook that we run for weekly reports, however daily we are adding new records also. Now, I want to know that how could I set auto sorting on two specific columns every time I open the ...
0
votes
0answers
36 views

Excel VBA Get the content of a string variable (my_name) from a cell with an address in other cells

in a macro I want a variable (My_name) to get a value (string). This value is in a cell of which the row index is in cell A1 and the column index in A2. Probably very easy for somebody with a little ...
1
vote
1answer
23 views

Can I code parameters directly into this macro or do I have to add them in each cell?

I'm using this macro to identify cells that contain non-alphanumeric characters: Function RegExCheck(objCell As Range, strPattern As String) Dim RegEx As Object Set RegEx = CreateObject("...
0
votes
1answer
64 views

Excel pivot values column to Text

I have data in Excel pivot and my text data in value column shows number instead of Text . Any one can help me please. In below image of pivot value field red circled:
0
votes
1answer
29 views

VBA for copy paste from file and sheet name as given in excel cell

I am using following VBA Code to copy data from a closed excel sheet. the name of sheet changes as per the date. so I assign the path and file name from the excel cell B1. Now I am stuck at one place ...
1
vote
1answer
50 views

Make rows mandatory if first cell is filled in

I have an Excel file where I want people to fill in specific stuff. I want to make a range of cells in a row mandatory if the first cell in the row is filled in. E.g. if cell A7 is filled in, cells B7-...
-4
votes
1answer
35 views

Macro is not working in 2016 Excel

Private Sub ListBox1_Click() Application.ScreenUpdating = False Dim Filepath As String Filepath = Worksheets("Postavke").Range("B1").Value & "\" & ListBox1.Value ...