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], or [microsoft-project].

1
vote
0answers
2 views

Is it possible to upload sections of a Excel List to a SharePoint List with VBA?

I'm setting up a new SharePoint List and I want to upload the first four/five columns to the SharePoint (They Match in Name and Contents) and then the 12th Column because it contains the SharePoint's ...
0
votes
0answers
24 views

Writing a macro that creates another macro

My current macro filters data in a massive workbook and pops out a new workbook with only the relevant data. The problem is that there are some calculations the end user needs to be able to have ...
0
votes
0answers
8 views

SQL CopyFromRecordSet got slow - Auto Wrapping and Sizing

Using Excel VBA to pull data from MS SQL into Excel. It is only 2,000 rows and 30 columns but it is taking over 10 minutes to execute the line ".CopyFromRecordset". I believe the culprit to be the ...
0
votes
0answers
12 views

VBA code to webscrape, loop through several account numbers

VBA code to webscrape and enter account numbers. I am trying to: 1)Go through each account number 2)enter it on the webpage 3)copy some data 4) paste into new sheet. I know it shouldn't be too ...
0
votes
0answers
11 views

Blank value when parameterizing SQL query

I'm having issues with apostrophes so I'm trying to parameterize to avoid them. This code runs without eror, but in the database instead of seeing "test" it's just blank. I can't figure out what I'm ...
1
vote
3answers
25 views

How to delete the active table row in a ListObject?

I have a userform for inputting new rows of data into a dynamic table that is synced to a Sharepoint list. I just need the VBA code for deleting the active row in the table only. I know this code is ...
-1
votes
0answers
12 views

Extract a specific file from a Zip file using unzip32.dll or dotnetzip in vba

I would like to use either unzip32.dll or dotnetzip to extract a specific file from an archive in VBA. I need some help in coding it in VBA
0
votes
0answers
37 views

Programmatically opening workbooks breaks events

I am generating a prompt list to open workbooks. However, doing so makes the event handlers in the opened .xlsm not run at all, but opening the same file directly through Windows Explorer works as ...
1
vote
1answer
13 views

Update Word bookmarks with formatted Excel data from Excel

The following code is intended to update Word bookmarks with formatted data from Excel, however the formatting doesn't come across and unsure why, would appreciate any suggestions. The formatted data ...
0
votes
0answers
26 views

Why is my quicksort not working properly?

I am working on sorting an array of objects in multiple ways. The objects are for areas, and I will be sorting data for those areas (more specifically population, concentration of water contaminants, ...
1
vote
2answers
21 views

How to populate a Collection with a function then call the collection to fill a combo box in a userform

I am pretty new to VBA, and I would like to fill a collection with a range of cells from a worksheet. I later will want to add and subtract line items, so I need it to dynamically include all rows I ...
2
votes
2answers
32 views

can't add 1 to current cell value

I can't get past this. I am try'ing to add auto numbering to A column, but for some reason I cannot add 1 to to the value. I am not sure why and maybe there is easier way to work around it ? all ...
0
votes
1answer
10 views

Problem with why the filter on current code isn't being applied to mails

I'm trying to set up a macro that will look at my sent items and delete any mails that contain "invoice" that are more than 30 days old. It currently works for emails older than 30 days but doesn't ...
0
votes
2answers
14 views

Looking to loop through a column in excel and highlight fill each cell if the content matches that of another column

I am trying to automate a manual process of cross referencing data and highlighting a cell if the contents are found anywhere in another column of data. However, the amount of data in both of these ...
0
votes
1answer
25 views

Return value from function to Cell

I am trying to return a value from a function and not sure how to go about this. The location I want to return it to is a merged cell from "G22:I26" on worksheets(1) and the original function is being ...
0
votes
0answers
20 views

How to merge date as date format(18/06/2019) and not number(43682)

I am trying to mailmerge a .docx thanks to a vba excel macro. It work perfectly for String but when I Want to merge a date as a readable date format it don't. To fix it i tried to use the following ...
0
votes
1answer
16 views

VBA - How to stop a sub with a key press, and resume again with another key press

I currently have a sub in the Sheet object that, depending on which cell is being selected, requests either a number to be put in, or automatically references a different workbook and pastes a value ...
1
vote
1answer
12 views

Get From, To, Subject and Date from Outlook Mail Item

I need help to add Date, From, To and Suject to construct a pdf filename. 'Construct a safe file name from the message subject Dim msgFileName As String msgFileName = MySelectedItem.Subject Set ...
0
votes
1answer
14 views

How I can hide text that is beetween special characters in Microsoft Word?

I'm trying to make a macro but I don't know where to start, I would like to hide some text between special chars like : !"#$%&'()*+,-./:;<=>[email protected][\]^_`{|}~ (including "space" char) For ...
0
votes
0answers
15 views

Userform data entry freezes when email macro runs on a blank value…?

So I have a userform that is used to enter data into a table. I have also implemented coding that sends an email to people in a list if you select the "Send Email" checkbox next to the list value and ...
0
votes
1answer
14 views

How can I apply apply filter to 3 different Colums of a worksheet

I have to apply filter to column J,F and AE of a worksheet, but when I ran the code all the filters are deselecting. Here is my Code: Worksheet("sheet").Range("J:J").AutoFilter _ Field:=1, ...
0
votes
2answers
22 views

How to look values within given range in cell where IF is runned

I'm trying to develop a limitation on a F2 cell wich has IF statment in it. IF statment needs to be executed first and only then limitation shuold come in place. Current IF statment adds two different ...
0
votes
0answers
23 views

How to have my recorded macro move to the next person in my list

I have a list that has names and I have recorded a macro to help me copy, paste, format and move to next names in list. It is working, however something crucial is missing because the macro does not ...
-1
votes
1answer
5 views

Pulling e-mail adress from website with VBA

I have a list of links an each link leads to homepage where one e-mail adress is listed. Is it possible with VBA to pull these e-mail into Excel somehow? I would appreciate any help and advice.
0
votes
1answer
15 views

How to copy excel embedded image to word header in table in specific cell?

I'm calling procedure from my main procedure to make header in word, that contains 2 lines of text, then image, then 1 line of text. I'm trying to do that with table that has 1 column and 4 rows. In ...
-1
votes
0answers
17 views

How to split comma separated values into rows or columns in Excel using vba? [duplicate]

I have string like this in single excel cell "+2,-2" expected result : +2 -2 in different rows is there any way that I can split comma separated into rows as shown in above ...
2
votes
0answers
21 views

Export excel file to text using vba, charset UTF-8

Do anyone know how to save as UTF-8 format? Problem is that I have scandinavian letters and ANSI do not support those. Sub savetoText1() Dim FileToSave As String, lineText As String Dim ...
1
vote
1answer
29 views

How to scrap a particular text from PDF using Selenium with VBA

I am doing a automation project, where it starts with opening browser, visiting a URL, logging to it, clicking on few links and finally click a link which opens a PDF file in browser itself. Now I ...
0
votes
1answer
47 views

Run-time error '1004' when creating macro to delete shape

What I have done is created a macro that deletes any images in a certain range of cells if an image is present Range("D199:U205" and then copies an image named "JB Sig" at the bottom of the sheet, and ...
-1
votes
0answers
12 views

how to select specific slide via VBA

I have an Excel with Macro which should: toggle to active PPT select slide "X" and delete graphs Go to Tab "X" in excel grab new Graph Paste onto the "X" slide repeat 5 times
-2
votes
0answers
10 views

Selecting a already open Internet Explorer using VBA

Selecting a already open Internet Explorer using VBA
-3
votes
0answers
23 views

How to work with VBA & formula to get count

I'm using below code which will copy & paste data between 2 sheet. It will copy specific range & paste it in next sheet last empty sheet available. Dim last as long Sheets("sheet1")...
0
votes
1answer
18 views

Insert Blank if Section ends on ODD page Word Macro

What I have to achieve: There are two types of data in my word document, "Summary" and "Royalty", can have multiple of these two section in one document. but always in same sequence "Summary -> ...
1
vote
1answer
37 views

how to change cells address

I hope someone can help me with this problem. I was looking for first non blank cell in column A for a merging range. I found the last cell with the value in that column, but for merging purposes I ...
0
votes
0answers
17 views

Failure when get data from sql to excel

ive tried many things to make this but i have no ideia how to fix it, i want to import sql users table to excel, im using this code : "Runtime Error '-2147467259 (80004005)': Automation Error ...
-5
votes
0answers
26 views

Copy text and image to outlook body from a single worksheet

Trying to replace outlook body text enter code hereSub CreateEmailfromTemplate() enter code hereDim wdDoc As Object enter code hereDim oRng As Object enter code hereDim obApp As Object enter code ...
1
vote
1answer
19 views

Select all unlocked cells under ActiveCell in same column

I'm trying to create VBA code which will let me select all unlocked cells in particular Column under ActiveCell. Trying to resolve it myself, I came across code which partly does the thing: Select ...
0
votes
0answers
16 views

Open “x” file triggered by email subject containing “x”

I'm trying to write a code to open an X file (.bat) when an email with X subject arrives. To explain a little more, i would like to automatically open a file when the associated email subject arrives; ...
0
votes
0answers
19 views

Application defined or object defined error after the sheet is protected with password

I have protected each sheet with a password by using a macro. After the protection, the addin is not working; it triggers the error 'Application defined or object defined error' I tried ...
0
votes
0answers
22 views

how to print a text file content in html using VBA scripting

//reading a text file in a variable Sub TextFile_PullData() Dim TextFile As Integer Dim FilePath As String Dim FileContent As String 'File Path of Text ...
0
votes
1answer
37 views

What happens with an instance if I create a new one with the same name in VBA?

I have a class called assetTransfer. If I have a loop and I create a new instance with the same name, what happens with the "old" one? For i = 1 to 10 Dim assetTransfer as New assetTransfer next ...
1
vote
1answer
21 views

How to repeat macro for entire sheet

First post on here so I'm sorry if this has been put in the wrong place or not enough information. Hopefully quite a simple one. I currently have a macro running on my worksheet but this only applies ...
0
votes
1answer
16 views

Changing filter value by reading value from a cell in VBA

I have a tab with slicers. One of the slicers filters the data by month. I'm trying to write code in VBA that uses a value in a cell on another tab to change the slicer filter. In this example, my ...
-4
votes
0answers
17 views

Word VBA Saves Pages as Separate PDFs

i need your help to create VBA code to split world file using specific word in the file . EX, I have many pages for employees in 3 regions , how i can split the pages using the regions ?? Note :...
-1
votes
0answers
9 views

Search for a string in a pdf file then copy the info into word/excel/txt file?

I'm trying to open a pdf file and search for a string or substring in order to get to the page that i need and then copy the information on that page (not the whole page, just part of it) in a word ...
3
votes
2answers
81 views

SQL 'CREATE TABLE' Syntax issue

I'm having difficulties identifying the syntax issue in the first CREATE TABLE statement, and sadly I'm unable to identify the issue. I'm receiving the following VBA error: Run-time error '3290' ...
2
votes
1answer
23 views

CommandButton on Worksheet not found

For following Code i get this error Method or Data Member not found. Private Sub Workbook_Open() Dim ws1 As Worksheet: Set ws1 = Worksheets("Sheet1") With ws1.CommandButton1 ' Error ...
0
votes
1answer
19 views

Looping through the Word Document and Replacing a String with PageBreak

I'm trying to create a few Macros for Word that will make my life a lot easier than it were before. My problem is the following: I want to create a Sub that replaces every occurrence of the string "#...
0
votes
1answer
29 views

Excel VBA missing Microsoft outlook 15.0 reference and “Error in loading DLL”

I have been given an Excel work book to fix. What ever I click I get “Error in loading DLL” (e.g. I cannot access the modules). I can also see "MISSING: Microsoft Outlook 15.0 Object Library" in the ...
0
votes
1answer
13 views

How to set connection string in excel to import data from sql?

I want to import data from 2 columns in SQL server, im following this code from http://buffalobi.com/excel/excel-vba-import-sql-server-data/, whats wrong? Private Sub CommandButton2_Click() Call ...