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
1 vote
1 answer
156 views

Why is my Excel macro running so slowly?

My VBA code in excel is running very slowly. How could I make this macro code to run faster? Sub Test() Dim i As Long For i = 1 To Rows.Count Statusupdate = Cells(i, 1).Value If Status = "Started" ...
Ole B.'s user avatar
  • 13
0 votes
2 answers
991 views

How do I normalize/flatten an Excel row with multiple values into single rows with single values?

source is on top converted to bottom I have an Excel sheet where my user has counted the number of animals observed during her flight. I have to find a way to split her input into multiple rows where ...
Layne Seely's user avatar
2 votes
1 answer
50 views

Excel search and replace with search result

Hi there I have an Excel file with 2 Worksheets, one is a table with some names and values. And the Other one is a list of the names, but with more information to it (CSV format). Worksheet 1 (Genus):...
matilarab's user avatar
1 vote
1 answer
95 views

Combine a formula from text in different cells

I would like a macro to create a cell containing a formula like: ='X:\Documents\Database\Database files[DatafileB.xlsm]computed'!A3 So that this cell uses the values of: Cell B1: The indicated cell ...
KennyKe's user avatar
  • 11
0 votes
0 answers
422 views

count the number of times a cell has dependents in excel VBA

In the picture, you see I have 3 columns. I have written the VBA code to show the count of dependents in C column. Here is code. sub countdep() ActiveCell.Offset(0, 1).Value = ActiveCell.Dependents....
Amin's user avatar
  • 46
0 votes
1 answer
831 views

Replace header text with excel VBA

I'm trying to modify my current code to replace specified words in a MSWord document. The whole idea is working but only for the body of the document and nothing happening in the header or in the ...
Marcellnoel26's user avatar
0 votes
1 answer
761 views

Copy and paste a row of data into separate rows and staggered columns using Excel VBA macro

I am trying to automate the following step. From a single row of Excel data, I would like to copy and paste each cell value into separate rows, but staggered by columns, as shown in the picture. Is ...
sjedi's user avatar
  • 3
0 votes
0 answers
768 views

Executing SQL query through VBA

I am new here, but I always check this website whenever I have issues with excel and so far you've always helped me! Now I have a problem with VBA: I want to "call" an SQL query through a macro, so ...
Lisa Sakajawea's user avatar
2 votes
1 answer
79 views

VBA Excel macro: keeping and deleting sheets based on data in cell

This may be a very simple question but I can't figure it out. I run a macro that creates 13 spreadsheets. Of those 13 spreads, several of them won't have anything in column A2. I would like to be able ...
Sly's user avatar
  • 21
0 votes
0 answers
64 views

vba script created and running in windows7 32 bit does not work in windows10 64 bit

I had created a billing format using VBA. It worked fine in Windows 7 32 bit, but does not work in Windows 10 64 bit system. I am getting the error RUN-TIME ERROR '1004' DOCUMENT NOT SAVED. THE ...
Brij Y.'s user avatar
-1 votes
1 answer
265 views

Excel Macro Help: Start at R 2, read Col B, WS 1, find same in Col E, WS 2, then copy cell in Col I, WS 1 into cell of Col G, WS 2

Need to make a Macro in excel to do this: Starting at Row 2, read Column B, Worksheet 1,(need to Prefix data with PW- and trim spaces at end of string) find same value in Column E, Worksheet 2, ...
Russell's user avatar
1 vote
1 answer
288 views

Excel, list comments then hyperlink to original comment location

I can use the function called ListComments() from https://www.myonlinetraininghub.com/working-with-comments-in-vba. ' ' Written by Philip Treacy ' https://www.myonlinetraininghub.com/working-with-...
Bobo's user avatar
  • 67
0 votes
0 answers
512 views

Macro to set custom follow-up flag for multiple emails

I found a code which I have been able to adapt to almost get me to where I want to; I want to be able to select multiple emails, then click a button to run a macro to set the flag follow up date to X ...
Garoe's user avatar
  • 1
1 vote
1 answer
747 views

How to shift cells to the left without affecting its "own column" in Excel (i.e. via VBA)?

COLS : NO | | B | C | | D 01 : 1 | | 8 | 3 | | 2 02 : | | | 4 | | 03 : | | | | | 04 : 2 | | 5 | 2 | | 6 How can I shift the values to the left and delete ...
user1148943's user avatar
0 votes
1 answer
73 views

Excel: Copy Paste Multiple Instances One String

I have a column containing the below values which need to be pasted in the next column say triple or more times depending on requirements. Already got an INDEX formula from another post that works but ...
Irvin's user avatar
  • 53
-2 votes
1 answer
698 views

Autopopulate one sheet when "Yes" is entered in a cell in another sheet

I don't know a lot about VBA or excel - so looking for lots of help!! :) I currently have a page set up like Picture 1. I would be typing "Yes" or "No" into the the yellow boxes. Upon entering yes, I ...
Sarah Afzal's user avatar
0 votes
1 answer
134 views

Copy conditonal format colour from range of cells to another range of cells

I have used the conditional formatting colour scale on a range of cells (BY11:CV20). I would like to copy the colour format of these cells to another range (AC11:AZ20). I only require the cell ...
Faaiza Haffejee's user avatar
2 votes
1 answer
1k views

Two-way connection between multiple cells and across multiple worksheets

I am looking to make a 2-way connection across 2 worksheets so that I only have to change the entry on one sheet for it to be changed on the other and vice versa. I found a good explanation here (I ...
Naan102's user avatar
  • 23
1 vote
0 answers
376 views

Excel VBA: How to Create Word Handouts via PowerPoint VBA?

Sorry if title is confusing. I'm trying to execute a multi-app sub that will ultimately e-mail a PDF attachment. The process first starts by extracting information from a CSV, which I've done, then ...
Starnes Student's user avatar
-1 votes
1 answer
90 views

Force "File Save As" immediately after workbook opens -- code not executing

I created a .xlsm wrkbk template with the code below (h/t mrexcel.com) embedded in a module in the macro-enabled template file. To prevent users from overwriting the template file, the macro should ...
Siuslaw Math's user avatar
0 votes
0 answers
784 views

VBA Macro Loop Until Blank Cells

I have a sheet with large data where I need to cut specific columns and paste in 1 column and have made a macro but need to loop it until it finds a blank cell. This is my code ' ' Column Macro ' ' ...
Irvin's user avatar
  • 53
0 votes
0 answers
61 views

How do I create a graph from two groups of data without selecting data row by row?

Say you have this data: First group of data: A B C D E a 0 1 3 4 5 b 6 7 8 9 5 c 0 1 2 3 4 Second group of data: A B C D E a 1 1 5 4 5 b 6 8 8 5 5 ...
Peter La Anguila's user avatar
0 votes
2 answers
6k views

Take active cells value and copy to another cell. Excel VBA

I am putting together a list to loop through in Excel. I want to loop down column A starting at A2, and copy the value from the active cell to D2 (always D2) This is what I have so far: Sub Test2() ...
PeterH's user avatar
  • 7,435
0 votes
1 answer
339 views

Why does my VBA function not evaluate the source cell that returns a HYPERLINK based on an IF statement

I have a cell with an IF function which either returns an empty value, or a hyperlink, based on whether another cell is empty or not =IF($R7="","",HYPERLINK(CONCAT('Global Values'!$B$1,$R7),"LINK")) ...
csharpforevermore's user avatar
0 votes
0 answers
35 views

Automate the specific format generation based on input in rows

I have a form of slip for payment to Govt. (call it "Challan"). Based on the input in the rows, the challan form fill-up can be automated. I want to keep the filled-in Challan form (each size a page) ...
Shibbir Ahamed's user avatar
0 votes
0 answers
125 views

From 1 module call macros from 2 separate modules

I have 3 separate modules embedded in the same active workbook (i.e. not in personal.xlsb). From the module named Run_DelCols_Del_NoComms, I want to call in consecutive order the macros from these 2 ...
Siuslaw Math's user avatar
0 votes
1 answer
144 views

Automatically selecting and deleting rows from another sheet

I have this code which is taking a number from H2 and by this number selecting X rows and print them. I can't figure it out how to delete the selection after printing them. If I do not clear H2 the ...
Bonch's user avatar
  • 3
0 votes
1 answer
851 views

Word Macro: Move line of text above previous line

I am trying to use the following code to move a line of text that begins with "File #" above the previous line of text, but I get a bad parameter error on the Selection.Range.Move object. For Each ...
Jamie's user avatar
  • 1
1 vote
0 answers
210 views

Set Excel cells or formula to background or low-priority recalculation

I have an Excel worksheet with a column of non-volatile formulas that are computationally expensive but low priority. So I don't care if they update infrequently, and would prefer that they do so in ...
feetwet's user avatar
  • 1,685
0 votes
2 answers
2k views

Excel VBA, define range with a variable that has it's value gathered from a cell

This is my code: Dim var As string var = Range("B1").Value Range("").Interior.ColorIndex = 5 Is it possible to define the last line like this in some way, and if so, how?: Range("var").interior....
Tom's user avatar
  • 59
0 votes
1 answer
170 views

Track changes in a sheet in Excel

I want to know if there's an event or function in VBA other than Worksheet_Change that follows changes in a sheet because Worksheet_Change is an event that gives me an immediate response and I want a ...
anne's user avatar
  • 35
1 vote
2 answers
1k views

Excel: VBA Calculation giving error on "blank" cell

My VBA calculation on sheet "$$$" in column L gives a "Runtime error 13: Type mismatch" when I run it, using the "original calculate balance" button. This is confusing because this has worked for ...
mechengr02's user avatar
0 votes
1 answer
2k views

How to get large Excel table to paste into multiple slides using vba?

I am new to this forum, and new to VBA. I am working with a very large Excel table (200+ rows) where I have added a code in to identify page breaks based on when a value changes in one of the columns. ...
alyssakptn's user avatar
0 votes
1 answer
890 views

VBA: Union function not working to delete non-contiguous columns

Using the UNION function, the code below should delete the entire column for specified cols B, D & F. I choose UNION function because several SE posts suggested UNION FUNCTION as most efficient ...
Siuslaw Math's user avatar
0 votes
2 answers
3k views

Excel VBA - "Run-time error 13: Type mismatch" when cell range is more than 1

I'm trying to use VBA so that a click of a button will save the worksheet as a particular name (which is linked to a certain cell), however, I want it to canel the save if certain cells are blank. ...
Reece's user avatar
  • 1
0 votes
2 answers
2k views

Excel used range has entire columns

I'm dealing with many Excel files, and often run into workbooks that are very large for the data they contain, or worksheets that are very slow when scrolling. On the way, I learnt this is often due ...
ElRudi's user avatar
  • 424
0 votes
1 answer
784 views

Open/read sheet-password protected `.ods` using vba from excel?

Scenario In an attempt to read cells from an .ods file that is readible and editable without requiring any password, but which has some data validation cells, I am experiencing slight technical ...
a.t.'s user avatar
  • 393
0 votes
0 answers
127 views

Is there a way to run ms access applications with vba code correctly on mac?

I am trying to run MS Access application that includes VBA code on a mac device but unfortunately, there's no access version for mac os. So I ran windows 10 on it using bootcamp and installed ms ...
Mahmoud Nasser's user avatar
0 votes
1 answer
461 views

Outlook VBA - A startup macro that moves incoming undeliverable (NDR class) messages for multiple shared inboxes

I have a little experience in Java but barely any in Visual Basic. I need to create a macro for my work Outlook that has 4 inboxes in the profile. One is my [email protected], another is for marketing@abc....
A.C.'s user avatar
  • 1
-2 votes
1 answer
127 views

Error 449 in Excel VBA

I got the following code Option Explicit Private Sub change(ByVal Target As Range) Dim a As Integer Dim z As Integer Dim q As Integer z=0 q=0 If Target.Address = "$F$2" Then z = z + 1 Else q = ...
anne's user avatar
  • 35
0 votes
1 answer
211 views

Automatically Hide/Unhide rows - questionnaire

Hi I need some help with my work sheet. I have to build a dynamic questionnaire and I need to have a code that allow me to hide/ Unhide automatically some rows base on a cell information. Example: if ...
Deni's user avatar
  • 1
0 votes
0 answers
222 views

Alternative for checking if cells change in VBA

Is there another way of finding if cells change in a worksheet other than the following? Private Sub Worksheet_Change(ByVal Target as Range) If Target.Address=$A$1 Then 'something End If End ...
anne's user avatar
  • 35
2 votes
2 answers
229 views

Button error in Excel

I made a Command Button in Excel with the code Private Sub CommandButton1_Click(ByVal Target As Range) Dim a As Integer Dim z As Integer Dim q As Integer z=0 q=0 If Target.Address = "$F$2" Then ...
anne's user avatar
  • 35
0 votes
0 answers
2k views

VBA: Error with specifying Range or UsedRange with AutoFilter

Code below should delete entire rows based on the condition that cells in BOTH Col C AND D in a given row are empty). The macro uses a filter to display only those rows meeting the aforementioned ...
Siuslaw Math's user avatar
1 vote
1 answer
493 views

How to make a macro out of a Private Sub?

I have the following code Private Sub Worksheet_Change(ByVal Target as Range) Target.Font.ColorIndex = 5 End Sub I want to make this code work in the worksheet, but it won't save as a macro or run ...
anne's user avatar
  • 35
0 votes
1 answer
177 views

How to prevent printing/saving of a file if certain cells are not modified in Excel?

I have a template worksheet in Excel in which I change certain cells all the time. The question is: is there a way to make Excel prevent me from printing or saving the sheet if some cells are not ...
anne's user avatar
  • 35
1 vote
0 answers
1k views

Copy arrows from conditional formatting

I am looking for a way to copy the arrows of the conditional formatting icon set. I want the arrows to be static when copied because the data should be linked to a Word document. The conditional ...
schiseb's user avatar
  • 11
0 votes
2 answers
917 views

Highlighting cells in excel based on another cell text that is derived from a formula

I want to highlight cells based on a set of values that is made from a formula. I have the data in the sheet from A2:D10 (can be text, numbers, anything). I have compared this data with another sheet ...
Rose's user avatar
  • 3
0 votes
0 answers
196 views

Given a path go to the sub folders and make a list of all Excel files

Given a File Path. I am trying to import all the (xlsx) files that start with '001-'100 within that folder (So far I am able to import them with the following macro) Sub Select_Folder() 'returns ...
Pepe's user avatar
  • 13
0 votes
1 answer
233 views

Conditionally update field in datasheet view when row is modified? [closed]

I have a requirement for an Access Database to add 3 new fields: [Entered By], [Entered On], and [Reviewed By]. Part of the requirement is that when the record is modified the [Reviewed By] field ...
Tyler N's user avatar
  • 983

1
15 16
17
18 19
75