Skip to main content

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
2 answers
1k views

Excel VBA Function Not Detecting Cells Colored by Conditional Formatting

I have a few conditional formatting conditions on my excel sheet that fill in cells with different colors. I am trying to count the number of cells colored by my conditional formatting in excel so ...
Stephen's user avatar
-1 votes
1 answer
311 views

how to merge two VBA codes in one?

I have these two VBA codes, to get the result, I have to put the following excel formula to do the trick : =CCPA(A1)&(MAJUSCULE(A1&MAJUSCULE(RIP(A1)))). I want to merge the two together in a ...
snollygoster's user avatar
1 vote
0 answers
62 views

Outlook rule to move a different email than the one that triggered the rule

I get a series of emails (separate, not in the same conversation) for approvals. The first email will have a subject line "ACTION REQUIRED: [XYZ] approval request." If another user ...
opilione's user avatar
0 votes
2 answers
205 views

How do I format a target cell based on a source cell, using VBA?

I'm looking to copy the format of a cell within the table table1 to cells with matching text within the second table table2. So for instance: NOT(H) is showing as green in table 1 and I want it to ...
Chris98's user avatar
0 votes
2 answers
34 views

Excel: is there a formula/code I can use to paste specific values based on a dropdown value?

I’m a new user looking for help on an Excel formula/macro code. To demonstrate my scenario, let’s say I have a drop down list with values of “Breakfast, Lunch, and Dinner”. If the user selects ...
190191cd's user avatar
0 votes
1 answer
1k views

How to deselect / select specific AutoFilter options consecutively using VBA?

I'm trying to create a macro which will allow me to deselect / select specific Filter options, consecutively. So in the below example, if I click "Deselect Type 1", then "Type 1" ...
Philayyy's user avatar
  • 129
1 vote
0 answers
193 views

Is there a way to show horizontal and vertical gridlines on a Surface Contour chart?

I am creating a chart of type xlSurfaceTopView in VBA. I want the chart to have horizontal and vertical gridlines, but the last two lines of the following With statement only cause two gridlines to ...
jisner's user avatar
  • 11
0 votes
2 answers
874 views

How to use Excel to produce Timesheet from MS Outlook calendar?

This question is mainly to share my idea. On daily bases I have problem to fill in my timesheet. I work different hours every day and at the end of the month I have to submit Excel timesheet that ...
Look's user avatar
  • 21
0 votes
1 answer
170 views

Excel for Microsoft 365: Change Width of Columns Based on Column Name in Header Row

I am using Excel for Microsoft 365. On the first worksheet, I have recorded a macro to adjust column widths and row heights. I then switched to the second worksheet and ran this macro and realized I ...
Dave's user avatar
  • 1,029
0 votes
1 answer
65 views

Is it possible to have bidirectional relationships in Microsoft Access?

I have a database including two tables for suppliers and people: the suppliers table has a look up column where one can select the people relevant to that supplier from the people table. and there is ...
Foad's user avatar
  • 662
0 votes
0 answers
55 views

Excel VBA - Words are not Replacing but PDF is generating

In this code I'm trying to replace specific words targeted by "#" in a template ms word file then generate a PDF and save the file but the problem is......PDF is generating but words are not ...
Manish Verma's user avatar
0 votes
1 answer
264 views

How to remove a command from a Word right-click menu

I've got four commands,Translate, Read Aloud, Link, and New Comment, in the Microsoft Word 2021 text right-click menu that I will never use just wasting space. How can I remove them? I've found code ...
user2609404's user avatar
0 votes
1 answer
70 views

Declaring variables vs using function directly

Is there any advantage in this: Dim LR As Long Dim LC As Long LR = ActiveSheet.UsedRange.Rows.Count LC = ActiveSheet.UsedRange.Columns.Count Cells(LR, LC).Select Over this: Cells(ActiveSheet....
leandro_shin's user avatar
0 votes
1 answer
108 views

How to stop VBA Timestamp code to update all cells that have this function on all rows everytime a change is made on some row?

Later edit: I now realize that it is because users insert rows and I think that is causing (all) the timestamp cells to update at every insert. Not sure how to overcome this issue. Basically, what I ...
Robert's user avatar
  • 105
1 vote
1 answer
98 views

Need a VBA Solution - Clear contents of 7 cells to the right of cell

I have a document where I need to look for a specific text and clear all text in the cells to the right of it. I don't want to delete the cells just clear them out. There are a total of 7 cells next ...
Rey's user avatar
  • 13
0 votes
2 answers
298 views

ObjExcel.DisplayAlerts = False is not suppressing the alerts and VBA code is not working as expected

I have below VBA code to copy the data from one sheet (Data is derived based on Formulas) to another sheet, but it's not working when I called from informatica tool as it's not able to handle below ...
Raju's user avatar
  • 11
0 votes
1 answer
348 views

My macros is disabled when I open a Word document via VBA in Access?

I have made a special template for the Word documents I create via VBA in Access - the problem is that the macros in that template are disabled ! If I create a new document by clicking the template ...
ksor's user avatar
  • 1
0 votes
1 answer
55 views

VBA delete rows when there is blanks or 1 or "Safe" but keep safe emply cell having 1 or "Safe" using formulla

I want delete blank cell from range of T2:T200 by keeping data safe if cell empty by "" or 1 (=if(b2<>"",1,"") or (=if(b2<>"","safe","...
Dinesh's user avatar
  • 1
0 votes
0 answers
147 views

VBA vlookup in another sheet [duplicate]

I have two Sheets (Sheet1 & Sheet2). Sheet2 has list of headers with numbers either as 1 or 3 in adjacent cells. Sheet 1 has same headers with values as "TRUE" or "FALSE" from ...
Rax's user avatar
  • 5
0 votes
1 answer
151 views

VBA if and vlookup on multiple columns

I have two tables (Table1 & Table2). Table1 has values as TRUE or FALSE. Last cell is the desired output. I want that if all values in Table1 are FALSE, my Output column should write 0. If any ...
Rax's user avatar
  • 5
0 votes
2 answers
2k views

VBA to copy value and loop for each row

I have range of columns with mostly blank cells. I am trying to copy if any of those cells contain a text. For this I have written the following code which works fine for the first row. How to repeat ...
Rax's user avatar
  • 5
0 votes
0 answers
106 views

Excel VBA Run-time error ' 1004: Application-defined or object-defined error

Can someone explain to me what's with this code...i'm new to vba codes Private Sub hide_Click() 'hide the userform UserForm1.hide End Sub Private Sub reset_Click() 'clear the input box TextBox1.Value ...
Manish Verma's user avatar
0 votes
0 answers
150 views

Excel VBA Help - PDF Export Run-Time Error

I have macro which generates PDFs from data I insert into a sheet. The amount of PDF I need to generate differs from week to week. I have button I click and it runs the following code. It copies the ...
Max's user avatar
  • 1
0 votes
1 answer
3k views

How do I add the median and average to a graph?

I have this graph which was composed from a dataset. I want to add a horizontal line at the Median (0.97), and a separate horizontal line at the Average (1.16). I need the horizontal lines to ...
Philayyy's user avatar
  • 129
0 votes
1 answer
19 views

Non-Conventional MSWord Formatting Using Baselines

I'd asked this question "yesterday" over on Graphic Design SE, but I was prompted that SuperUser would be more useful in what I'm trying to accomplish. My question is regarding the use of ...
anon5001's user avatar
1 vote
1 answer
560 views

Generate label cards from an Excel sheet

I work with list of archaeological finds in Excel spread sheets provided by volunteer archaeologists, which contain various information on the site, geographic coordinates, the type of find, date of ...
C.-F. Vintar's user avatar
-1 votes
1 answer
191 views

Populate cells on one sheet from data on another based on a user-defined variable that dictates the range

I'm trying to build an inspection report template for solar installations and am somewhat new to complex Excel usage (and brand new to VBA), but very comfortable with programming and learning fast! ...
KDavidson's user avatar
2 votes
1 answer
162 views

Bubble Sort (or Similar) Excel VBA with single and multivariable criteria: Solve for lowest sum

Long time lurker first time poster. I'm working on an Excel project to solve for the best (lowest value) combination of vendors and achieve full criteria coverage. The exercise is fairly simple for 95%...
Nate Z's user avatar
  • 21
0 votes
2 answers
256 views

How to properly and efficiently query Lots of data from SQL Server putting it into specific cells?

Recently I was asked to make a real-time project in Excel which evolves huge amount of data. I have this data stored in SQL Tables and managed to successfully bring it into Excel. SQL Table on Excel: ...
Fróis's user avatar
  • 13
0 votes
1 answer
63 views

VBA's ASC() function returning random values for special characters, only on my machine

When running this piece of VBA code on my colleagues computers, the value of temp is 176. Sub Test() Dim temp as Integer temp = ASC("°") End Sub This is appopriate, since this is ...
Arthur Attout's user avatar
0 votes
1 answer
2k views

VBA to find Specific text in a range of columns

I have value as "TRUE" in columns B to H. I want my macro to return "FALSE" in column A if any of the cell in range B:H contains "FALSE" else "TRUE". And do it ...
Rax's user avatar
  • 5
0 votes
2 answers
79 views

Copying of invoices using vba

I would like to know how I can copy multiple invoice details like, Customer Names, Delivery address from sheet 1 onto a Invoice template. I want to be able to create a new sheet that has all the ...
Nikhil Ramdeyal's user avatar
-1 votes
1 answer
56 views

VBA/auto sorting help on EXCEL

I am trying to put VBA code that makes it so that when I automatically input values into a table they are automatically sorted. It was working for some of the charts, but now only the last chart ...
Seb's user avatar
  • 1
0 votes
0 answers
2k views

Extract All Comments from PowerPoint File into a Text file

I have a monthly PowerPoint reports that I create with relevant notes in the PowerPoint notes section. I would like to just extract these notes from the PowerPoint files over the years. Is there a VBA ...
DigitalNomad's user avatar
  • 1,708
1 vote
0 answers
228 views

Excel VBA Macro: Formatting Duplicates and Uniques

I have a spread sheet where each row consists of information about a member of a group. In each cell of column B there is an integer that represents each person (i.e., think of an member ID). All ...
ccwv4372's user avatar
0 votes
0 answers
735 views

How do you get the raw data of an Excel file?

The European Union (EU) provides an Excel file that has data on trade between various countries. Their Excel file, however, only shows data between countries based on a filter function. It seems they ...
Will M's user avatar
  • 101
0 votes
0 answers
142 views

Excel Macro error prompting Save As dialog box with weird file name

I made a code for a friend something like this : Sub SaveToMainData() Application.DisplayAlerts = False Application.ScreenUpdating = False pfn = ThisWorkbook.Path & "\Backup\MainData.xlsb&...
karma's user avatar
  • 111
1 vote
0 answers
45 views

Skip rows with NULL value

I have this code I have been using to find the 50% exceedance value per hour and month. Attached is a picture of the data. There are some NULL values in the Gen columns and I need the code to skip ...
Sam's user avatar
  • 11
3 votes
1 answer
664 views

Automatic reply in Outlook when out of office

For my e-mail account on a Microsoft Exchange Server, I would like that, for each email received where the following two condition are met : I am in the to: or in cc: I have an "out of office&...
TheSunnyDay's user avatar
0 votes
1 answer
241 views

VBA to copy and paste Range Values is too slow

I'm using this code and it works just fine but it runs very slow. Does someone has a different approach for this? Sub CopyPaste() Dim sourcerange As Workbook Dim currentrange As Workbook Dim r As ...
Carlos Juarez's user avatar
0 votes
0 answers
66 views

How to cut row from sheet1 and paste onto sheet2 - excel

i need help. I have multiple sheets. Rejected Candidates Interested Candidates Candidate Track Onboarding Track Now I have these formulas: =CHOOSECOLS(FILTER(Interested_Candidates,...
Nik's user avatar
  • 9
2 votes
1 answer
236 views

Avoid repetition in writing an expression in VBA Excel coding

I have written a code in VBA Excel, a part of which is repeated several times in the entire code. for example: sheets("A").range("A1").select ... sheets("A").range("...
First Last's user avatar
1 vote
1 answer
239 views

Outlook VBA - linked image in ReplyAll mailitem created from Custom from template not displaying

The below code creates a mailitem from a custom Outlook Form Template and a ReplyAll mailitem and appends the ReplyAll mailitem to the Template mailitem. However, the image icon from the Outlook form ...
sifar's user avatar
  • 111
1 vote
1 answer
308 views

Calculation of mathematical text in textbox

Is there a function to calculate the mathematical text in the text box in VBA? For example, can we calculate the expression 1+2 entered in the text box? I have used the calculate option in Word using ...
First Last's user avatar
1 vote
1 answer
986 views

Excel Sheet save as pdf

I have a VBA macro that saves an excel file to the same directory as it is in. This performs well and as expected. What I want to do is to save the file as a PDF. I have tried various bits of code but ...
Alan-53's user avatar
  • 33
2 votes
2 answers
505 views

Macro to find and move specific cells

I need a macro that finds each cell in (Excel) column A that begins with an * (asterisk plus space) and moves it one cell to the right and one cell up. Then goes to the next * cell in column A and ...
Ash Grove's user avatar
1 vote
0 answers
221 views

Excel VBA Data Validation to check if data validation in the table has failed

My below code does two things wrong. First, it checks for data validation for all the cells in the sheet even if those cells are outside the DataBodyRange of the table and shows MsgBox "Failed&...
Jawad's user avatar
  • 111
0 votes
1 answer
149 views

Why is conditional formatting in an .xlsm not printing?

I have an xlsm workbook that colours cell backgrounds based on comparison to adjacent worksheets. The adjacency is always 1 to the left, irrespective of whether sheets are inserted or deleted. The ...
J Collins's user avatar
  • 708
1 vote
1 answer
561 views

Create a macro on Word to save with current name at a different location

I have a Windows 10 PC. Basically I have a similar problem to this: How can I save a file to two locations at the same time?, but just the opposite. I have files on a USB stick, and I want them to be ...
George Lee's user avatar
0 votes
1 answer
717 views

Excel VBA - Copy data from multiple sheets into a table

I'd like to be able to copy data from multiple sheets into a table without deleting the table's formatting. The data being copied from each sheet will always contain 6 columns But the number of rows ...
Nev's user avatar
  • 1

1 2
3
4 5
76