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 votes
1 answer
124 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
117 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
199 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
51 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
70 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
49 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
1k 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,678
1 vote
0 answers
187 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
396 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
112 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
42 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
532 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
171 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
94 views

Excel formula or VBA to create simple coversheet calendar from multiple worksheets

I have several worksheets that I want to create a simple calendar with. Every month I will be creating a new workbook. I don't even know where to start.... Detailed operating information is on each ...
Tina's user avatar
  • 25
0 votes
0 answers
59 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
213 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
200 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
241 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
688 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
374 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
174 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
119 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
  • 678
0 votes
0 answers
302 views

Hardcode Values from Formula in VBA

I work at a library and I write VBA Excel scripts for librarians from time to time to automate tasks, ones revolving around gleaning info from reports usually. I have a data-loving librarian that ...
Jordan's user avatar
  • 37
1 vote
1 answer
467 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 ...
new editor's user avatar
0 votes
1 answer
581 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
0 votes
0 answers
59 views

Error in duplicate record in Access 2010 [duplicate]

I should work with a database into the Access 2010 recently. It has few Tables, a few Queries based on their tables and finally a Form. The Form has a button for duplication records. When I click the ...
Kasy's user avatar
  • 1
1 vote
1 answer
3k views

Excel VBA - add date and time to a file name as FILENAME_MMDDYY_HHMMSS

A few weeks ago I posted about using VBA To prompt me to add a file name when saving an excel file using a macro. Thank you for all the help. I got it to work!! Now I have another similar question. ...
Kirk Thompson's user avatar
0 votes
0 answers
112 views

Prevent VBA from duplicating dropdown list selections when entering manual text

I'm using a VBA code for a dropdown list with multiple options in Excel, but when I enter text manually in a cell that already contains one or more selected options, the code duplicates the previous ...
Tom's user avatar
  • 1
0 votes
0 answers
2k views

don't want to automatically add "@" symbol in excel formula

I am adding a formula using VBA in a excel cell and excel automatically adding a "@" symbol after the "=" sign. this is the vba code. It is putting the whole string as formula but ...
Ayan Bhunia's user avatar
0 votes
2 answers
57 views

Cut entire cell, based on specific text in cell, and paste to new cell

I have a six-column table in excel that I am using with a barcode scanner. We are scanning custom QR codes that display text into each cell. The scan starts with scanning the employee's QR code on ...
btwolfe's user avatar
3 votes
1 answer
367 views

How to cross join in Excel VBA

I want to cross join two columns from a sheet and paste the result in another sheet using VBA. Cross join of column A and B from Sheet1 and paste result into Sheet2. I found two answers but not able ...
Ayan Bhunia's user avatar
0 votes
1 answer
76 views

Change text color of URL in Word VBA

After the URL is displayed beside the hyperlink, the formatting from the hyperlink is applied. Is there a way to remove the blue, bolding and underline formatting for the URL. Current format: My ...
Dingleberry's user avatar
0 votes
1 answer
77 views

look for empty cell between non empty cells in one row and then put 0

enter image description here enter image description here A B C abc 30 40 def 4646 ghi 45 3234 So, I want to write a macro code where it takes all three columns into consideration at once....
Aadya's user avatar
  • 1
0 votes
2 answers
238 views

Insert URLs in plaintext after each hyperlink in MS Word using VBA

I would like to automatically insert the URL for each hyperlink in a word document beside the linked text. For example instead of having: my hyperlinked text It should be: my hyperlinked text (https://...
Dingleberry's user avatar
0 votes
1 answer
896 views

Set default zoom in Excel on a new sheet

I have set zoom level when new workbook is open with this code: Private Sub Workbook_Open() ActiveWindow.Zoom = 109 End Sub How to I set custom zoom on every new sheet that's created in that ...
IGRACH's user avatar
  • 481
1 vote
1 answer
195 views

How to fix vba type mismatch?

I have a compile error message byref argument type mismatch pointing to rg1 where the HTML is. Could you please help? Sub email_multi_ranges() Dim OutApp As Object Dim OutMail As Object Dim rgl As ...
tammy's user avatar
  • 13
0 votes
0 answers
149 views

VBA: Compile Error: Syntax Error when trying to use Cell.Replace VBA code

Hi I'm new to VBA and I've created a code to format my Table however I receive an error "Compile Error: Syntax Error" when trying to run it. I have tried to look at the code but I can't seem ...
slimbu2020's user avatar
0 votes
1 answer
300 views

Excel: Extracting the row name and column name corresponding to the MAX value in my DataTable

In cell K1=MAX(J7:AM36) I have the maximum value of the data table, I want to extract the corresponding StopLoss% ( This is my column headers, they are %) to Cell K2 and also my TakeProfit% ( This is ...
Steven's user avatar
  • 3
0 votes
0 answers
80 views

cannot find next item in findNext loop

I loop through Items in an array raArray which I want to find in a Table. However, I cannot seem to get the code to work to find the next result for the array element with FindNext. Either I get stuck ...
user1769136's user avatar
0 votes
1 answer
402 views

Update a field in other records based on the value of same field in a record automatically

I want to transfer the contents (value) of a field in an Access form by VBA to its previous and next records, while I am still in the current record. Could be said I want to copy it to the same field ...
Kasra's user avatar
  • 39
0 votes
1 answer
39 views

continue searching for string in Table until no more results are found then go to next search term

I have a working code that allows me to find a string in a table and returns the value of an adjacent cell (adopted from a different code) and writes it to an array Dim raArray As Range Dim iC As Long ...
user1769136's user avatar
0 votes
0 answers
21 views

write avg subtotal in filtered list "in-line" with month

I have a list of values, where want to calculate the average for each month based on the subtotal(101) function. Each month has a different amount of values (e.g. 5 values for March, 17 for July). (...
user1769136's user avatar
1 vote
1 answer
65 views

Custom Information Message for user based on another cell value

I am busy with an optimization spreadsheet which needs to display an information message, maybe similar to the Input Message for data validation (but I am open to suggestions). This message will be ...
IzakG's user avatar
  • 21
1 vote
0 answers
49 views

Clicking on an unlocked cell on a protected sheet is unprotecting the sheet

I have a workbook with multiple sheets. There are unlocked and locked cells. I have a macro to protect all sheets. After I run the macro and all sheets are protected, when I then click on a cell ...
Ana's user avatar
  • 11
2 votes
0 answers
41 views

Why does certain data imported from Word into Excel have yellow font, but not in Word?

Students fill out some tables in Word, and they must occasionally use a certain color font to get full credit. I'm using VBA to import their data and the color of their font from their submitted ...
Starnes Student's user avatar
0 votes
1 answer
6k views

Reoccurring Out of Office Every Other Week Outlook

In Outlook, is it possible to set a an out of office automatic reply every other week on the same day? e.g. every other Monday. I see a solution here using headers for every week: https://answers....
sushi's user avatar
  • 115
1 vote
1 answer
101 views

Excel VBA - Copy a formula result to a cell in another sheet + add succesive formula results in consecutive rows each time the formula is recalculated

I am running a partially randomize set of data and trying to find the best solutions depending on certain parameter changes. I need to "record" certain solutions and then compare different ...
Bao bab's user avatar
  • 11
0 votes
0 answers
789 views

How to import multiple csv-files in Excel at once with VBA

I am trying to import multiple csv-files within the same directory into my Excel sheet using VBA. The following code is working very well with just one csv-file. But I lack the knowledge to adapt my ...
Caroline's user avatar
1 vote
0 answers
50 views

Creating .txt files from excel columns with description [closed]

I am trying to create .txt files that have the following: Txt file name would be cell(A1) Content of the txt file needs to be the content of cell (B1) Repeat throughout the column I am new to VBA and ...
Abdullah Al Jaja's user avatar

1 2
3
4 5
75