As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [vba]

Visual Basic for Applications (VBA) is an event-driven, object-oriented programming language for writing macros, used for the entire Office suite as well as other applications. VBA is not equivalent to VB.NET, or VBS; if you're working in Visual Studio use [vb.net]. If your question is specifically about programming any MS Office application, also use the appropriate tag: [excel], [ms-access], [ms-word], [outlook], [visio], or [ms-project].

Filter by
Sorted by
Tagged with
0 votes
0 answers
5 views

How do I correct this getelementbyclassname error?

WebsiteI am trying to get a price from a website, but I keep getting error 91. My code works accept for it won't select the actual price [number] 0.00014 [highlighted in red in the pic]. It's on this ...
SuZiee's user avatar
  • 1
0 votes
0 answers
10 views

Accessing a Word document from Excel VBA fails on second execution

I have a simple Excel VBA routine. It simply creates a Word object, opens a Word document, does a replace of one string in the document with another, then saves the result as a PDF, closes the ...
Lindsey's user avatar
  • 13
0 votes
0 answers
13 views

VBA USERFORM BUTTON CAPTION COLOR / NONUNIFORM

Is there a way to make it so when a VBA MS Word Userform toggle button is clicked only part of the caption text changes colors? E.g. "Upper (case) / Lower (case)." Upper turns from black to ...
Ken's user avatar
  • 1
0 votes
0 answers
14 views

VBA AutoFilter filtering out rows outside of set range

I've got a worksheet that has a section of rows in the middle of it that blank cells are filtered out using AutoFilter successfully using a range to specify which rows to filter out as per below With ...
halma562's user avatar
0 votes
1 answer
11 views

How to go about repairing Compile error - expected identifier

could someone point me in the right direction with the following error message please. Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _ ByVal bScan As Byte, ByVal dwFlags As Long, ...
Adamf13's user avatar
0 votes
1 answer
19 views

VBA script won't run. Getting Run Time Error 424 Object required

I am getting a run time error when I try to run this. Can anyone solve this? Sub recolor() 'Sub Color_Change Dim rng As Range Set rng = Range("A1:E16") If Not Intersect(Target, rng) Is ...
LA1312's user avatar
  • 3
0 votes
0 answers
15 views

Removing a drop down list option based on previous cell selection

Overview of worksheet I have created a dependent drop down list in a cell that changes according to a data input in another. I want to be able to automatically remove a listed option in a third cell (...
Manhattan's user avatar
-4 votes
0 answers
18 views

Excel / VBA function to calculate arrays of medians/averages [closed]

I am creating some templates for work where we use a software which gives us output in the form of a number of dynamic arrays. The length of the arrays are (obviously) dynamic but always the same for ...
user17491878's user avatar
0 votes
0 answers
26 views

Getting MS ACCESS error when exporting to PDF (can't save file)

I had this issue for a long time, then I had this pretty consistent working but had to make a change on the database and now it's acting up again. It's not always erroring out, but very frequently. ...
Ron2020's user avatar
0 votes
1 answer
16 views

502 Bad Gateway Error when trying to make a request to ANEEL API using VBA

I'm having an issue with the ANEEL API query through a macro in an Excel spreadsheet. Although I can successfully make the request in a browser, I'm unable to write some fields in the Excel table due ...
Mateus De La Fuente Cezar's user avatar
0 votes
2 answers
46 views

Excel Regex VBA

I need to extract a part of string from an excel cell if it matches the following format: "DDD/L-DDD-L/DDD-L-DD/DD" where D represents any digit and L represents any letter, upper or lower ...
ARC11's user avatar
  • 3
0 votes
0 answers
17 views

Ms Access VBA: Why is this date comparison not working?

I am trying to compare 2 dates. One of them is stored in my SQL Server database, the other comes from user input on a form. I am entering 6/5/2023 for the end date and 11:54 AM for the end time and ...
TheMortiestMorty's user avatar
-2 votes
0 answers
18 views

VBA Type Mismatch Issue - adding variables fixes the issue?

I'm having an issue where I am splitting data between Excel workbooks. My variables are defined as... Dim dt As Date Dim d, m, y, fpath, strFileExists As String Dim tempV1, tempV2, tempV3, tempV4 As ...
Dennis's user avatar
  • 17
0 votes
0 answers
25 views

This code is to get the data from inv sheet column N to sheet rep column B Run-Time Error "1004" Method 'Range of object_'worksheet' failed

This code is to get the data from inv sheet column N to sheet rep column B fw2 = Me.ListBox1.ListCount - 1 Inv.Range("B9:N500").ClearContents Inv.Range("B8:N" & 8 + fw2).Cells....
Mohamed Amin's user avatar
0 votes
0 answers
18 views

Insert a blank row above , "True" which is in column "T"

I have a worksheet, which is populated from another sheet, which can have a variable amount of rows. In this worksheet I am trying to insert a blank row above , "True" which is in column &...
FNormN's user avatar
  • 1
0 votes
0 answers
26 views

Unable to sum each element of 2 arrays within VBA to create a single array which contains the total

I have a range of cells within excel which I want to assign to a 2 dimensional array within VBA. Once assigned to the array I want to keep adding to this array based on updated values calculated ...
Guv24's user avatar
  • 1
0 votes
1 answer
31 views

How to Assign a Macro to a Form Button, Using VBA

I am attempting to create a "Export Button" the button currently creates a new workbook with specific sheets from the existing one, unhides them and inside one of these sheets contains a ...
Jamie 's user avatar
  • 101
0 votes
0 answers
38 views

How can I get one excel cells value to stay one step behind a change in another cell?

Introduction: Thank you for taking your time to read this to help me and teach me. I am new to Stack Overflow and would appreciate any and all constructive criticism. I am open minded and happy to ...
Brinn's user avatar
  • 1
0 votes
0 answers
17 views

Get current users in Excel shared workbook (co-authoring)

Background I have a shared workbook on a team's document library site, I would like to know the users that have the Workbook opened in VBA on demand by VBA. Problem The VBA code that I have found only ...
Sgdva's user avatar
  • 2,775
0 votes
1 answer
34 views

Data moving not following vba script

This is what I am looking for in the script Get the information of the raw data sheet distributed over the different spreadsheets if value in column J matches name of the spreadsheet. If value in ...
Vario84's user avatar
0 votes
0 answers
32 views

immediate window: clear before debug.print

I would like to add a code to clear immediate window. When programming I like to use debug.print. To make the debug.print a bit more convenient, I wrote a small code below. A problem occurs, when ...
CAtr's user avatar
  • 1
-3 votes
1 answer
41 views

vba to copy a row and insert to row below and then repeat

I would like to copy and insert a row, ie row 10 and insert to row 11. I would then like to run that code again (via a command button), to copy row 11 and insert to row 12. I would like to be able to ...
elmo51's user avatar
  • 1
0 votes
0 answers
34 views

VBA Access / Picture sent in body (not attached) by automated E-Mail

I'm 100% new in VBA world and also here in "Stackoverflow". I am currently working on a code that automatically sends E-Mails. Code is written in VBA-Access. What I'm interested in is how ...
Mare_KST's user avatar
-1 votes
1 answer
23 views

XML VBA Merge parent nodes with the same values

Good afternoon, I ran into a problem when exporting an xml file using a VBS script, the structure has this form: <?xml version="1.0" encoding="windows-1251"?> <Documents&...
Вадим Любарский's user avatar
0 votes
0 answers
36 views

Writing a file from object

I want to write a text file that contains all the data from within an object. I know how to create and open a text file using vba, also how to write from a range or string going through every line but ...
vba_enjoyer's user avatar
1 vote
0 answers
16 views

ActiveWorkbook.conflictresolution xlOtherSessionChanges throws error

I would like to ask if anyone encounters this problem with excel vba conflictresolution / resolve conflict. I create an excel file called test.xlsm and convert it to a shared workbook over the ...
xingtan's user avatar
  • 53
0 votes
0 answers
14 views

Powerpoint VBA - move the inserted audio after the existing animation

I have number of animations on a slide e.g 4 mainsequences. For each of animation, I want to insert relevent sound to start with the animation. I have the following function: Option Explicit Function ...
rahmaddanis's user avatar
0 votes
1 answer
38 views

Removing empty rows and shifting remaining rows up in a range before copying and pasting another range

Still learning the ins and outs of VBA. I have two ranges: (A:E) and (F:J). They need to be condensed into a singular range. The first range has empty rows, which need to be deleted. After these rows ...
Newt's user avatar
  • 15
0 votes
0 answers
22 views

Can only delete 100 records on SharePoint list using VBA

I have a VBA that upload/edit/delete items on a SharePoint list using ADODB. Everything worked fine for months until June 1, 2023. Now I can only upload/edit but cannot delete more than 100 records on ...
RenanSchwyz's user avatar
0 votes
0 answers
56 views

VBA macro identify the case number

Collapsed Data tried with 80,000 cases: =COUNTIFS($F:$F,"*"&RIGHT(F2,6))*1 i tried this formula for some values its shows 3,4,14 in column that the reason for the mismatch I tried to ...
Sudharsan R's user avatar
0 votes
0 answers
28 views

How to save a new excel file with multiple sheets and with vba scripts that runs in those sheets

EDITED Hi I am trying to save a file from a parent file which has filtered data in a sheet and in the other sheet if values of some cells are changed, in turn changes the value in the first sheet. It ...
Himanshu TOMAR's user avatar
-2 votes
0 answers
26 views

Filter a checklist when a checkbox is selected and filter a table list in a different sheet when combo selection is done [closed]

I'm new on VBA and I'm trying to insert two different macros to retrieve: an autofilter on the "Months" list, depending on a checkbox "Season" selection='True' an autofilter on a ...
MeSa's user avatar
  • 1
-3 votes
1 answer
22 views

force correct date format in a userform in vba

I have the date set to the format 29/8/2023 in the general settings on a mac. I am using excel 2016 and have a userform where a date is entered into a text box. I have tried various ways to check that ...
chris's user avatar
  • 25
1 vote
0 answers
40 views

Resize Range to omit/exclude the empty columns

In the below code I do a manual selection and then extend/ resize this selection to a specific cells SelectedRange on the same row(s). The finalRange may contains some empty cells on the the right ...
Soma's user avatar
  • 491
0 votes
2 answers
27 views

Display Hidden Lines (Solidworks macro)

I want to set the appearance of a single part I selected in an assembly to Display Hidden Lines with a macro. The file I am using is not a drawing, not a part file. assembly file. part will not be ...
ömür tokman's user avatar
0 votes
0 answers
19 views

Inserting a New Column Between Existing Columns in VBA

Inserting a New Column Between Existing Columns in VBA I have a requirement to insert a new column between two existing columns using VBA in Excel. For example, if I have columns A, B, and C, I want ...
PabloZ392's user avatar
  • 101
0 votes
0 answers
21 views

How can I use VBA to separate data in a long column with occasional dates at the beginning of some rows?

VBA For Excel - Need to run a text to columns action for slightly different rows in the same column Hi, I am trying to write a VBA script for separating some data that appears in long rows of text/...
Cacodemon's user avatar
0 votes
0 answers
18 views

Userform with listbox

I have a Userform in CATIA Macros that includes a listbox. The listbox contains calculated data, and these calculations are updated when the user clicks the "preview" button. However, if the ...
Salome's user avatar
  • 1
0 votes
1 answer
21 views

Pattern to extract all matches of URLs within a string

I have some URLs like this http://app14.co.ad.local:90/ATT\me1111419.org within a string. The numbers of dots . and backslash \ or forward slash / is not constant. The URLs start with "http" ...
Leedo's user avatar
  • 419
0 votes
0 answers
23 views

Why does my chart ignore a VBA command, and how to prevent it?

95% of the time the code I'm using will work fine, producing some gauge charts by using a doughnut-pie chart combo. One requirement in this is that the Doughnut portion be plotted on the secondary ...
Starnes Student's user avatar
2 votes
2 answers
45 views

Taking multiple arrays to multiply different ranges in excel sheet

I am trying to multiply different ranges in an excel sheet and running them when the multiplier value changes. Sheet 1 has : A B C D ABC 10 20 2.5 DED 5 15 1.7 Sheet 2 has: Column A2 : "5%&...
Himanshu TOMAR's user avatar
-3 votes
0 answers
27 views

File Management Automation in Sharepoint using Macros or Power Automate

I am creating a power BI dashboard for my team and I am not sure how to technically achieve this. We get an excel file from upstream on a monthly basis which contains sales data by each member and I ...
haleem3388's user avatar
0 votes
0 answers
25 views

VBA Accessing a nested value in record set

I am querying Active Directory from VBA which returns a recordset. I access the values returned in the recordset "rs" per the code below: Set rs = cmd.Execute adUser.Add "givenName"...
Al Grant's user avatar
  • 1,955
-3 votes
1 answer
28 views

why does wba exel code show me <> when i add an espace after the last letter of the word

Why does if condition show me <> when I add an " " after the text Option Explicit Sub Compare_Two_Excel_Sheets() Dim j As Integer Dim i As Integer Dim k As Integer Dim ...
Ahmed Mattoussi's user avatar
0 votes
1 answer
31 views

encoding='UTF-8' Open strFile For Input As intFile [duplicate]

the following code vba does not read Persian letters with a proper encoding ; encoding='UTF-8' Dim strFile As String Dim intFile As Integer Dim strBody As String strFile = "C:\Plus.csv" ...
saeidmobashery's user avatar
0 votes
1 answer
20 views

Unprotected Excel Sheet Runtime 1004 error - can't set numberformat of Range

I have a simple sub running on togglebutton click as part of a larger vba project. Neither the workbook or sheet are protected. I want to set the format of an output cell (E18 on the same sheet as the ...
Aragorn2001's user avatar
-1 votes
1 answer
17 views

Toggle Button Excel Vba

I wanted to know how do I keep a toggle button in the on(true) position after I close the userform and re-open Nothing. thatsway I need your help to sew if i can set my userform as i think before. May ...
Carlosjr's user avatar
0 votes
0 answers
26 views

How can I copy building block text and formatting between different Word templates using VBA?

Platform Laptop computer App: Word 2010 OS: Windows 2010 Prerequistes In Word 2010, two test templates are used named tpOP.dotx and tpSRC.dotx, tpOP is the document template already open in Word in ...
Cudgel's user avatar
  • 1
0 votes
1 answer
35 views

How can I use SendInput function in VBA to combine keystrokes for Chrome window?

I want to use Sendinput function of Windows API in VBA to send a combination of keystrokes to a window, for example Ctrl H to Chrome. I choose sendinput() because sendmessage would not allow me to ...
Lv Linh's user avatar
  • 31
2 votes
3 answers
64 views

In Excel using VBA or formula, how to generate in single cell a comma-separated list based on complex criteria?

I am looking for an Excel formula or VBA solution that generates the result in Table2 column Party based on the data in Table1 and the inputs in Table2 column N. The inputs in column N of Table2 are ...
user1574881's user avatar

1
2 3 4 5
4191