Click here to Skip to main content
15,891,757 members
Everything / VBA

VBA

VBA

Great Reads

by William Hey
Classical number theories
by bradyguy
An end to end view of how to integrate Jira REST API's with Excel.
by RB Starkey
How to create a tree-view control using an Access table and form.
by William Hey
Semi-Prime Ordered Sequences (Part 2) is the follow-on to “Exploring Computational Number Theory (Part 1)” and describes a process for ordering the semi-prime base sequences.

Latest Articles

by NewPast
Indent code, add line numbers, err handling, add number to words and more, expose a .NET library to Microsoft Word, Excel, Power Point macros writers and Access VBA code
by NewPast
Floating point numbers as approximates and understanding error happened when using single and double data types
by Patrice T
The Excel Tools I crafted to simplify my life as programmer
by Mirzakhmet Syzdykov
Development process in few steps with the help of scripting software

All Articles

Sort by Updated

VBA 

19 Oct 2016 by #realJSOP
You also need to encapsulate a field with double quotes if the field itself contains one or more double quotes.
10 Jun 2018 by #realJSOP
All exposed classes and methods have have the comvisible attribute. If textsharp classes/methods don’t have that attribute, you’ll probably have to write a wrapper assembly that does it. I’m just guessing, I don’t know anything about itextsharp, and abhor MS Access and VBA.
5 Nov 2020 by   Forogar  
We are getting an unexpected (massive) slow-down in an Access 2016 VBA application over Citrix. No code changes, possible anti-virus update, possible Windows update, possible Citrix and Security updates. Perhaps the number of records has...
19 Apr 2023 by 2011999
Excel column "A" more than Duplecate Names(in Different locations same Company Name), Column "B" Person Name, C Column Date given. Company Name Per Name Date A Column B Column C Column ABC Company aaaa 12/01/2022 ABC...
20 Apr 2023 by 2011999
Excel column "A" more than Duplecate Names(in Different locations same Company Name), Column "B" Person Name, Column "C" location Name. Column "D" Value. Column "E" %Value Column "F" Date given. Example: XYZ C***ry Company...
21 Apr 2023 by 2011999
I am using AGGREGATE Functions in MS Excel 2007, i got this error #NAME? using this function DATE Column, i tried SUBTOTAL instead of AGGREGATE. but not worked. What I have tried: i used this Function =IF($G55 ...
2 May 2023 by 2011999
A1 Cell in Excel address had Web Site URL, how to Assign that URL to Button VBA MACRO when click the button web site will open, and how to assign that URL in Variable. in that button already had Code. when click the button two tasks will RUN it...
24 Jul 2023 by 2011999
In My VBA CODE Working in Laptop but not working Desktop in Laptow OS WIN 11 amd Excel 2010. Desktop OS WIN 10 EXCEL 2010. how to Resolve This ERROR. What I have tried: im URL As String Dim ie As Object ' InternetExplorer Dim HTMLDoc...
8 Sep 2023 by 2011999
Workbook in Sheet1 Column I in Cell Value is 0.06% and more on how to convert percentage format to Number Format after convert number format cell value is 0.06. But I got the result of below code as 0.00. I need output of result as 0.06. What I...
13 Sep 2023 by 2011999
I am trying to get Table Data. See below code. What I have tried: Sub ScrapeLondonStockExchangeData() Dim URL As String Dim HTMLContent As String Dim HTMLDoc As Object Dim Table As Object Dim Row As Object Dim Cell As...
2 Oct 2023 by 2011999
How to resolve this "Object required" error on Micorsoft edge Windows 10 and Office 2010 in not working VBA Code but not working in Windows 11 in Office 2010 working below code. What I have tried: Sub ScrapeTableDataWithHyperlinks() Dim URL...
12 Jan 2012 by 3lb3njy
Hello i need a bit of help.I just managed to run a .exe front Access 2000 with the command Shell ("root/name.exe"), but now i need that the new window(my outside app) shows up in the front window, because when i run the Shell command it comes minimized.Ty in advances
12 Jan 2012 by 3lb3njy
thanks.i used a variant Dim name as Variantname= Shell("root/name.exe",vbMaximizedFocus) or the vbNormalFocus was good also, but thanks :)
8 Aug 2016 by 99Freddo
I have tried the following code copied from various websites but I am no programmer. I want the image to load at the right hand side of the screen in Word opposite the cursor position. Currently it loads at the top of the document or the centre of the first page if I use.Top =...
10 Oct 2011 by @BangIndia
i want to delete the files in the internet temporary files .. Location is "C:\Documents and Settings\users\Local Settings\Temporary Internet Files"if i try to delete from the files it not showing .i use cmd prompt to delete it..but if i try to search the files the cmd prompt...
11 Oct 2011 by @BangIndia
i am using msdev editor for my c++ programing..i have one vb script.. But i want to do same operation using my c++ program..if any one explain me how..Set objFSO = CreateObject("Scripting.FileSystemObject")objFSO.DeleteFile("c:\dmmm\df\*")how to write the same coding in c++
12 Oct 2011 by @BangIndia
i use msdev ..i use wmi to create the subkey in registry..i use void CreateKey()method.But it create only the sub key..i want to create the Dword value.. how to create that in any language but using wmi..
21 Nov 2010 by @nuraGGupta@
pass the search string (employee id) to another form.Suppose you have forms Form1 and Form2. You want to navigate from form1 to form2.Do it like this,on the button click event on form one,Form2 objForm2= new...
18 Nov 2014 by @SkyHigh34
I am trying to write a function to uncheck the four filters within one hidden dropdown list, automatically the pages loads with the filters checked; below is the source code ...
22 Jan 2015 by @SkyHigh34
I am currently autofiltering a range of data, I copy my filtered data to a new named range.When I run the code below; in my userform Listbox, I get a row from the source range outside of my identified range below "rlist" with duplicated results inside the listbox around 50 time? thank you in...
7 Sep 2015 by @SkyHigh34
I have an Excel spreadsheet that I would want an image from sheet 2 to appear in an ActiveX Imagebox1 on sheet 1 when I click on the cell that is located in sheet1. I am new to VBA, any help would be appreciated. Thank you
23 Jan 2015 by _Asif_
One solution could be to store all these parameter information in some form of XML. Then at run time you can load this XML in memory and then have a function which creates parameter by reading this xml. This will definitely reduce your code base significantly but it will increase your memory...
13 Sep 2010 by _Damian S_
There is a Site Bugs and Suggestions forum where you can post this kind of thing. The site owners/managers/hamsters get emailed automatically when you post an item there.
10 Aug 2011 by _Damian S_
There are two general ways to achieve this. One is to bind the data to your form, the other is to use a SQL statement (whether that's by query or hand coded) called from an event behind the form, say the on click event of a Process button or something similar...
5 Feb 2015 by _Geoff
I know it has been two weeks since you posted, but fwiw, I think this could help.Using a step value of 15 in a for loop and incrementing the starting value in each iteration should take care of what you need easily. This first code is hard coded with the values you provided and should be...
3 May 2013 by _Marshall
Without being able to see your data this solution is a good starting point.Public Sub coltorow()Dim rng As RangeDim i As Long, newSheetRow As LongDim rngValues()Dim lastrow As Long''Variable to keep track of row on new sheetnewSheetRow = 1''Determine last row of data on...
19 May 2017 by AAB40
Hi, I'm trying to add an XML file in my excel workbook on sheet 2 to create pivot tables. Everytime that I import an XML file, another excel workbook is opening. How can I change this please? So, to make my actions clear: Open Excel on sheet 1. Click 'Open folder' in the start menu of the excel...
29 May 2017 by AAB40
Hi, I went a week on vacation and apparently it did me a good thing. It works now. Added the code in a new excel sheet and the uploaded XML file is opening in sheet 2.
30 May 2017 by AAB40
When I'm running my code I have a runtime error on Sheets2.UsedRange.Columns.AutoFit could someone tell me why please? The reason of this ActiveX button click is to select all cells in sheet 2, autofit the columns and select particular columns to change the font of it. Thanks in advance. What...
29 May 2017 by AAB40
I've made it to add an xml file in sheet 2 of the present workbook in excel using VBA. Though every time I click the button, excel is nevertheless adding a workbook in my Original workbook. How can I code this for it not to happen anymore please? What I have tried: Private Sub...
17 Feb 2016 by aakar
Hi All,I have my data in the below format in an excel sheet.Location Dept_Name Alloc%New York Finance 50.00Stockholm IT 45.00Geneva Services 30.00New York IT 50.00Stockholm Services 45.00Geneva IT 60.00Stockholm Finance...
15 Apr 2019 by Aaron Queenan
It's a bit late to help the original poster, but in case anyone else finds this article, here's an explanation of the problem. Although other content controls support standard (MSXML3) XPath syntax, the repeating section content control only appears to support very simple XPath syntax, allowing...
13 Sep 2013 by abbaspirmoradi
Create a loop and add data to your collection in the loop.Then check if collection contains value show error, Else add data to your collection..For Each input As var In inputList If OrdLines.Any(() => { }, str.Item1.Contains(firstinputvalue)) Then ' show error ...
10 Jul 2013 by abdulsafran
Hi,My problem is I have large amount of data and need a simple VBA to do the below task. If you give me a start then I can do rest of the work. Kindly check and let me know. Your soonest response is highly appreciated.if (B1=B2 && C1=C2 && D1!=D2)...
16 Aug 2014 by Abhijit Ghosh (Subho)
I am trying to parse a string to get something like a formula out of it. My question can be best explained by the following examples:example 1: (12345 in year 1 / 23451 in year 0)-1)*100solution1. (2. /3. )-1)*10012345, 123451, 0example 2: [[1234 in year 1) - (4567 in...
26 May 2011 by Abhinav S
Len should be returning a numeric value - so you should not be comapring against '10' but rather 10.This line should look like sql = sql + "Where len([" + fld.name + "])
26 May 2011 by Abhinav S
You need to close the file before deleting it.There is no way way the delete script will work unless the file has been closed.
21 Jun 2011 by Abhinav S
This[^] existing discussion may help you.
1 Apr 2012 by Abhinav S
Maybe you are referring to some article you read on the internet.In this case, please provide a reference to the article so that someone can help you.There are a couple of articles on printing a grid view that could be of some assistance in helping you solve this problem.Printing a...
10 Dec 2013 by Abhinav S
Try these linkshttp://en.kioskea.net/forum/affich-30153-copy-rows-based-on-a-condition[^]http://nerds-central.blogspot.in/2007/01/excel-copy-and-paster-cellsrowscolumns.html[^]
25 Mar 2014 by Abhinav S
You could count the number of page breaks[^]. That would give you the number required.
2 Apr 2014 by Abhinav S
Ensure a sheet by the name Sheet2 exists.
1 May 2014 by Abhinav S
You have used many subqueries. Check each of these to ensure they don't return more than one query.
8 Nov 2011 by ABISOYE
I am working on the electric power house simulation using nth generation. I want to have idea of code on how to enter my data using excel vba userform into the excel worksheet and how to generate random number.
6 Jun 2014 by Access Guru
How do switch from overlapping window to tabbed window in ms access 2000 and older versions through vba code....
6 Dec 2012 by Adam R Harris
The path of least resistence to get this out of excel would be to copy and paste it into notepad then save its [something].vba. Then all you would need to do is just double click the vba file and your process would run. Outside of that you are going to have to pick a language, most likely...
3 Feb 2015 by adam.m.b.nelson
Hello,I'm working in VBA (in excel specifically). I need to pull data out of poorly formatted text files. I have my search functions working, but am trying to streamline the code (remove redundancy).Specifically I want to hand a function to run when a successful search is caried out,...
2 Nov 2013 by Adam_adam
Hello All,I want to update multiple rows in ms access project table from different queries, by using vbamy database on sql server 2005. please could you help me and send me some information for it.with regards
6 Aug 2016 by Adam_adam
I have an MS Access application that contains all tables linked to SQL Server, so in MS Access VBA code I work with those tables very simple, I access them via name, like [Customers].Also I have a stored procedure in SQL Server called sp_CopyData which I need to call from my VBA code. I...
29 Apr 2018 by Adeel M
I have list of all 10000 url's in excel sheet, is there easiest way i can make automation job to open each link and save the Phone number and email data in excel sheet. http://scci.com.pk/member-detail.php?id=1 http://scci.com.pk/member-detail.php?id=2 ...
6 Aug 2012 by Aditya Mangipudi
Check the original document. Here is a link for what all you need to checkhttp://www.404techsupport.com/2009/01/microsoft-word-this-modification-is-not-allowed-because-the-selection-is-locked/[^]
27 Nov 2011 by ahawari09
Hello,Dose anyone know the answer why excel closes down when scrolling down the mouse on listbox? Is there anything I should adjust in the properties? Thanks.[EDIT]Moved from comment - LOSMAC[/EDIT]I am using excel 2007, and this is the code used on listbox and it is populated with...
24 Jan 2019 by ahp-1984
I have one Excel Macro which has VBA Code and this macro has reference to some other VB .dll so I need to debug excel macro along the reference of VB projects could you tell me how I can debug ? What I have tried: Tried to open excel file in Visual basic
12 Aug 2011 by Ajain A K
I want to copy data in one sheet of workbook to another I want to generate a new workbook based on sheet of data in another workbook. How record or use I use macro to do this task, for reference I am attaching the excel sheet please have a look. The excel sheet is site.xlsx, this work...
30 Nov 2011 by Ajarwe
Hi Everybody, I am working in VBA exercise using worksheet_change event,I was trying to change multiple cells in excel so that Change event should fire.But issue is, when I change single cell Change event gets fired ,not allowing to change multiple cells.I want to change multiple cells so...
1 Dec 2011 by Ajarwe
Hi All, Am working in Automation of PPT Slides from Excel using VBA.I have more than 50 slides,and more than 100 tables.If I change values in Tables it should reflect in PPT slides.I have written code using ActiveCell like This Public Sub UpdatePPT_Click() Dim MyPath As String ...
3 May 2012 by ajeanson
Hi,I'm using vba code in Access 2007 to read excel files to feed Access tables: Set cn = New ADODB.Connection With cn .Provider = "Microsoft.ACE.OLEDB.12.0" .ConnectionString = "Data Source=" & source & ";Extended Properties=Excel 8.0;" .Open End...
4 May 2012 by ajeanson
Solution to my pb:It seems that there is no EOF if they are more than 32K rows.To detect the EOF and exit the 'while' loop I need to check if the data in the excel record set is not null. stillData = True While (Not rsEX.EOF And stillData) If IsNull(rsEX!Date) Then...
17 Jan 2020 by akash.jagad@gmail.com
I need a help to get vba code with variable that can search value from "text" sheet to "Check" Sheet. I have prepared the code but can not create loop for "Text" sheet form cell value A2 to A4 one by one. Please help for that. I have created below code Which shows 1004 error. and i am also...
22 Oct 2012 by aksh619
i am working on a macro that will transfer the data from multiple workbook files with differents worksheets to one work book with 2 worksheet Example Like i have 3 workbooks as (A)sales order with coulmn (1.)orderno (2.) orderdate (3.)shipto (B) shipment ...
22 Oct 2012 by aksh619
i am creating a macro that transfer data from one workbook to another. i am getting a error please help. i have taken command button on workbook on b.xls which will run this.Private Sub CommandButton1_Click()Dim wkb1 As WorkbookDim wknm As Stringwknm = "d:\a.xlsx";Set wkb1 =...
24 Oct 2012 by aksh619
what i want to do is here.. i want to take B2 cell value from Workbook Wkb2 And match it with the other workbook wkb3 and if it is not present there than append that that coulmn value ata the end of the work book . Please some one help me out Also giving error on select2 =...
25 Oct 2012 by aksh619
This code works fine but only for single value . But i want to apply for every coulmn cells like A1 Coulmn cells Set wkb3 = Workbooks.Open(wknm2) For i = 2 To 100 For j = 2 To 100 select2 = wkb3.Sheets("Sheet2").Range("A2").Value Set wkb2 = Workbooks.Open(wknm1) select1 =...
25 Oct 2012 by aksh619
i want to find the last empty row for a particular coulmn like A coulmn . sub abc()iRow = wkb1.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).RowEnd Sub as this is taking only first coulmn and providing me with Irow = 2 but there is data present on second B coulmn ....
31 Oct 2012 by aksh619
its giving error on irowtro error is out of range please help me Sub transferorderdata()Dim wkbor, wkbvl, wkbysd, wkbtr As WorkbookDim wknm, wknm1, wknm2 As Stringwknm2 = "C:\vbproject\tracker\ysdflow2.xlsx"wknm = "d:\a.xlsx" '-------Open orderwknm1 = "d:\SAMPLE.xlsx"...
1 Nov 2012 by aksh619
i am developing a macro which will first transfer and remove. i am using concatenated fields someone help me .. Option ExplicitSub transferorderdata()Dim wkbor, wkbvl, wkbysd, wkbtr As WorkbookDim wknm, wknm1, wknm2 As Stringwknm2 = "C:\vbproject\tracker\ysdflow2.xlsx"wknm =...
3 Dec 2014 by Aksh@169
hi, I am trying to generate a xml in below format.i am new to this. can somebody help me in this.''' ' Global''' 09/2014''' Customer Order management - Performance...
9 Oct 2011 by Alex Odhiambo
i would like to know how i can set the columns and rows of a MSFlexGrid fixed to the windows, and also updating it with text boxes, any kind of help shall be appreciated, thank you
26 Jan 2015 by Alexandros Pappas
This article proposes a way to do book-keeping for home use.
2 Dec 2013 by AlexDpars
This should be helpful for you.
21 May 2015 by Alexey Shtykov
Convert column numbers to range letters and add comments
19 May 2015 by algor-AG
VBA: Excel / Word programmatically save document as PDF encrypted / password protected.
17 Jan 2014 by Ali_Abdelrhim
' This function open the excel file in excel application and get all the work sheet names and return it as array Private Function getExcelSheetsName(ByVal Excelfilename As String) As ArrayList Dim objExcel As Excel.Application Dim objWorkBook As Excel.Workbook ...
31 Mar 2014 by Ali_Abdelrhim
This is the line that get the sheets field name:Dim sheetName As String = "[" + arrList(0) + "$]"the number (0) is for the first sheet, (1) for the second one and ... so oneThanks.
16 Jun 2014 by alireza ghasemi
Hi MastersI developed a VBA software in Excel. I want to publish this software but i want to add this software to excel automatically by create a setup.I am using InstallShield 2010.Would you please help me?Best regards
16 Jun 2014 by alireza ghasemi
hi DearHow to add .xlam Project in excel add-ins by registry?
9 Nov 2014 by Allen C. Copeland Jr
A guide on querying Excel ListObjects (Tables) by creating a state-machine out of synthesized objects that resemble a query language.
8 Jul 2014 by alonetmr
Hi everybody,Does any body knows how i can get the WorkSheet in WorkBook1 and put it in Worksheet2 of Workbook2 by clickling a bottom?I need a macro to do that.I try to modify some code but it doesn't work. Here is the code:Sub test()' Get customer workbook...Dim customerBook As...
17 May 2017 by Alshaikhli
Hii, I have two worksheets in my Excel file, so i want to select and copy the columns (Part_Number,Name,Version,Level) from sheet1 to sheet2 in same workbook when the (Level) column include cell >1. the below code copy the columns from worksheet 1 to work sheet 2,but i still can not set the...
18 May 2017 by Alshaikhli
I have searched but i could not found anything related to my wish. I use vba to copy cells from one worksheet1 to worksheet2 with some conditions and it's working correctly. Now i face problem (Losing Formatting) when i copy it to another worksheet that include Template. what i need to copy...
2 Jan 2012 by Amir Mahfoozi
You should make it first visible then send keys :Dim xl As New Excel.Applicationxl.Workbooks.Addxl.Visible=True xl.Sendkeys("H")xl.Sendkeys("I")I tested it with CSharp and it works well.If you insist on having excel hidden so you can not use SendKeys you should write...
12 Oct 2011 by AnamikaBhattacharya
You can create it by creating a COM object.Ex.HRESULT hr;CComPtr pDisp;hr = pDisp.CoCreateInstance( L"Scripting.FileSystemObject" );//creates the objectATLASSERT( SUCCEEDED(hr) );CComDispatchDriver disDrv( pDisp );CComVariant funcArg( LPCTSTR(_T("D:\\test.txt")) ), ret( false...
24 Oct 2011 by ANANTH P
Dear Sir/Madam, I need the macro coding for setting the cursor position at the top in a word document using Ms Word........
1 Dec 2023 by Andre Oosthuizen
Yes, it is possible in C#, VB.NET and some others as well. The below is for C# to reference your question - You can pick up on all of the basics as a starting point at - How to access Office interop objects | Tutorial[^] Some code to point you...
15 Apr 2024 by Andre Oosthuizen
As Richard mentioned above, you have no code showing how you are going to loop through the mail items. You also need the 'Outlook.Items' and 'Outlook.MailItem' objetcs for it to work properly. Normally I will not show pointers with as little...
3 Mar 2012 by Andreas Gieriet
You may be looking for the Gestalt Approach as described in Dr. Dobbs Article of July 1988: Pattern Matching: the Gestalt Approach[^].Maybe, this[^] article helps too.CheersAndi
15 Feb 2011 by Andrew Brock
It is not related to your actual question, but it is a problem none the less.Double numbers can have decimal places, hence the following code will not work correctlyint calcgrade(double average, char& grade){ if (average
4 Oct 2011 by André Kraak
Use the DataGridViewColumn.ReadOnly Property[^].
8 Oct 2011 by André Kraak
Are you sure the connection opens correctly, you have no error checking in place. So if opening of the connection fails you continue as it was opened and you are performing operations on a closed object.
11 Oct 2011 by André Kraak
Have a look at this: http://www.daniweb.com/software-development/visual-basic-4-5-6/threads/51162[^]
13 Oct 2011 by André Kraak
Have a look at SetDWORDValue[^].
3 Dec 2012 by André Kraak
You can use Workbook.FollowHyperlink[^] to open an application.See Open any file or application[^] for some examples.
4 Dec 2012 by André Kraak
This should help Excel Macro Recorder[^]
29 Apr 2013 by André Kraak
Try it with:.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Data.mdb;Jet OLEDB:Database Password=♣;" Alt+1029 is not 'converted' and should be entered as '♣'.But Connection strings for Access[^] contains the comment Quote Connection strings for Access[^]:Some reports...
1 Sep 2011 by andtherus
Hello, This is my first post on this site. I would like to request some help to code up a macro to do the following: I have two different real-time data feeds (via a DDE / ActiveX) that are going to 2 worksheets within the same book (say Sheet1 and Sheet2). What I need is: 1. Take the last...
28 May 2015 by Andy Lanng
I suggest you do some reading :/Get started with Access programming[^]
6 Dec 2016 by Andy Lanng
It looks like all of your casing is off. User this segment:With objAppointment .Start = DateValue(dDate) + TimeValue("08:00") .End = DateValue(dDate) + TimeValue("09:00") .AllDayEvent = False .Subject = sSubject ...
24 Jan 2017 by Andy Lanng
Depending on the types of values (if there are any formulas etc) then you could write your data to an array and then paste that to a range.The array must always be 2d, even if one of those dimensions is only 1 in length; That doesn't matter in your case as you will have a 2d array to paste