Tagged Questions
Visual Basic for Applications (VBA) is an event-driven, object-oriented programming language for writing macros, used for the entire Office suite. If your question is specifically about programming Excel, Access, Word or Outlook, use the appropriate tag: excel-vba, access-vba, word-vba or ...
0
votes
0answers
2 views
vba runtime error 424 object required - string indexing
I looked at the other links and none seem to help me out. I am writing code for a program that will count all the commas in a phrase. I am not new to programming but I am new to VBA.
Sub examp()
Dim ...
0
votes
1answer
9 views
I am trying to run this vba any suggestions
I am rookie in this any suggestions for running it
Private Sub CommandButton1_Click()
Dim LU As Double, HG As String, CN As Double
LU = Range("B1").Value
HG = Range("G1").Value
If HG = A Then
...
0
votes
0answers
4 views
vba .restrict [Start] gives too many items Outlook 2013
In Outlook 2013
Simple code:
sFilter = "[Start] >= '02/27/2014 12:00 AM' AND [End] <= '04/01/2014 12:00 AM'"
Set olAppts = olBulkAppts.Restrict(sFilter)
returns the dates within the range ...
2
votes
1answer
17 views
How to require excel 2010 workbook to be in specific filepath in order to open with VBA?
I would like to require a workbook to be located in a specific file path to open. I am using VBA in excel 2010.
(Project / ThisWorkbook code:
Header: Workbook / Open)
Private Sub Workbook_Open
...
0
votes
0answers
16 views
Mysql recordset creation
I want to select the list based on some condition. Let's say, table in mysql database has two column. One is item_id and another description. I want to select description list to be appear in combobox ...
0
votes
1answer
22 views
EXCEL VBA Write - Read File - BUG?
I've been wracking my brains with a file input problem, I've finally got it down to two problems, I can get past the error 62, "Read past End of file", but this one I can't get past.
Can someone tell ...
0
votes
1answer
13 views
vba html dropdown without options
I'm trying to use VBA to access a website and download some information. In the website are some drop-down boxes that need to be selected before the submit button can be clicked. I figured out one of ...
0
votes
2answers
24 views
Selecting a whole column as a range rather than a named range
What I have:
I have drop-down list in my form that I'm populating from a
worksheet.
My code only works for named ranges.
What I need:
I need to populate my drop-down list from a whole column ...
0
votes
1answer
15 views
Macro Fails, 'The macro may not be available in this…'
Hello and thank you in advance for your assistance.
I have some code that I admittedly borrowed from a site. It changes the sheet that is being displayed every X seconds. In my case 3 seconds. ...
-5
votes
0answers
22 views
insert the path in front of the file name [duplicate]
I have a column with file names such as:
test1.pdf
test2.pdf
I want to insert path like *C:\documents* in front of each file name so that I get output like
C:\documents\test1.pdf
...
0
votes
1answer
17 views
Inserting 4 Rows
I am trying to insert one row when the cell is column 4 doesn't have the same value. For some reason it is inserting 4 rows. It only happens at the start. What could be wrong?
Thanks for your help!
...
1
vote
0answers
14 views
Enter Javascript Form on webpage using VBA
Source code:
<TD VALIGN="BOTTOM" HEIGHT="24"><A HREF="javascript:processSearchForm
(document.frmSearchForm)"><IMG SRC="/RDPANN/pbs/images/funcsearch.gif" BORDER="0"
WIDTH="68" ...
0
votes
1answer
5 views
Insert Source Url when Importing XML using VBA in Excel
I've got the VBA script working to scan a list of XML files and then import them into individual worksheets:
Sub adds()
For x = 1 To 5
Worksheets("zips").Select
Worksheets("zips").Activate
mystr = ...
0
votes
0answers
11 views
Dynamically created link in powerpoint via VBA
I'm creating a gameshow powerpoint using this tutorial as a base for my code: https://www.youtube.com/watch?v=FdzdPCHqD5w
In my game though, I have a userform ask for a name and allow you to choose a ...
0
votes
0answers
14 views
WrapText,vertical alignment and filling borders of a range of merged cells in VBA?
After I remove the links from the selected range I want to return the cells to their original style/format. I am trying to do this by wrapping the text if needed,adding a border and aligning the text ...
0
votes
0answers
17 views
Include cell value in Macro code
I have a macro to open a workbook and start a macro from that workbook. I need to use this macro on different workbooks every time, though.
For example:
I have 2 workbooks - Sunday and Saturday + ...
2
votes
1answer
28 views
Use a method on multiple sheets simultaneously without using ActiveSheet or Select
EDIT: I realize my problem is more general in nature, so I edited the title accordingly.
The problem I'm having is fairly simple to describe.
It has been drilled into my head (through lots of ...
0
votes
0answers
12 views
Code to terminate query if there is no connection
I have some codes that run at startup of opening a DB, one that checks for connection to the sql server and then one that uploads data to it. The connection check is the first piece that runs. If ...
0
votes
0answers
19 views
Do While - Overflow error
This is my first VBA code:
Sub ConvertDec()
Dim colNum As Integer
Dim i As Integer
Dim x As Integer
colNum = WorksheetFunction.Match("Quantity Dispensed", ActiveWorkbook.ActiveSheet.Range("1:1"), 0)
...
0
votes
0answers
16 views
Excel VBA - Changing shape values on a locked worksheet
Evening All,
I'm faffing around trying to use Excel Shapes to mimic an ActiveX TextBox control, so the text will change depending on the Range selected. I want to keep the worksheet protected so the ...
0
votes
0answers
24 views
Getting the value of a number cell with VBA in Excel
So I have section columns which look like this:
8.01
8.02
8.03
8.04
8.05
8.06
8.07
8.08
8.09
8.10
And so on and so forth. I have it set up so that it will always show the trailing zeroes (8.10 and ...
0
votes
1answer
19 views
sql query - sql where clause using multiple criteria in where clause
I am new to VBA. My database is Ms-access. I wrote the query to extract the data from database based on four criteria.
My Database:
KeyerName Job score date time
xxx 1 50 ...
0
votes
1answer
25 views
Add extension .PDF at the end of file name
I have a column in the Excel sheet that contains the file names without the file extension.
How can I with help off VBA add .PDF at the end of the file name, so that I get a column with the file ...
0
votes
0answers
25 views
What commands to use when creating a vba excel macro
I'm trying to write an excel macro that does a simple calculation using values in existing cells and outputs a value. I basically want to write a formula that takes column a and column b and does the ...
0
votes
0answers
30 views
VBA Excel if value not found then add something to worksheet
i have a small program that works as a cash register. the user enters an ID number into a user form that populates the user info from the spreadsheet. everything works, but i want to add ...
0
votes
0answers
33 views
VBA clear all cells in range without a background color
Original Question: I have a large spreadsheet where I need to remove the contents of all cells that are not highlighted (have a background color).
*Problem Solved: the cells were actually white and ...
0
votes
2answers
22 views
Press enter in textbox and execute button function in VBA
I have a login form to my database done in Access 2010 and using VBA code. I want to be able to press enter on txtboxPassword and automatically execute btnLogin_Click event. I tried this:
Private Sub ...
1
vote
1answer
26 views
Access VBA Recordset
I have an access database that contains a table with employee information. My issue is that I want to loop through another table in order to determine if a specific characteristic is true or false ...
1
vote
2answers
21 views
How to call a Macro when a named range (cell) is changed
I am trying to call a macro named "RE_environmental" when the cell named "RE_1" is changed (i.e. they mark a X in the cell). I've tried several different variations of codes including these two and ...
0
votes
1answer
32 views
Associating a vb Object to a specific worksheet
I'm working with VB in Excel (Office 2010).
I have a class called Problem and a vb code that generates random problems and for each problem creates a new worksheet and prints the parameters of the ...
1
vote
1answer
15 views
MS Access Error 3622 vba
I have an Access 2010 database that was local and I have since linked to a SQL 2012 database. However, I have a form to insert a highlight record that runs the below code:
Private Sub ...
0
votes
3answers
44 views
Next Without For / For Without Next Error
I have the following code...that I've discussed before on here. It's been evolving though, so it's a little different now, I think.
Option Explicit
Public i As Integer
Public oOccurrence As ...
0
votes
1answer
29 views
Identifying different dynamic array VBA Excel
Here is my problem:
I would like to have a dynamic array where the user have the possibility to add new parameter in an Excel Array (typically by adding new row using a buttom).
I have then to stock ...
0
votes
0answers
19 views
VBA macros in an Add-in
I have several macros stored in an Excel 2010 add-in. One macro is saved in the add-in "This Workbook", and is set to run on Workbook_Open. All it does is create a MSObuttoncontrol for the other ...
0
votes
0answers
23 views
Excel: Getting macro results to worksheet 2
I have a macro with a button on worksheet 1 and I want the results to appear on worksheet 2, I can do this from within VBA, but not by using the button
Sub URL_Static_Query()
With ...
1
vote
1answer
14 views
VBA Access import Field doesn't exist in destination - Fieldname is garbled
I'm importing a *.csv file into an Access table with the following code:
DoCmd.TransferText TransferType:=acImportDelim, TableName:="FCS_Strategies", FileName:=.SelectedItems.Item(1), ...
0
votes
2answers
15 views
Copying visible/filtered rows efficiently in excel
I am working with some very large datasets (various sheets with 65K+ rows and many columns each). I am trying to write some code to copy filtered data from one sheet to a new empty sheet as fast as ...
1
vote
1answer
25 views
Data type mismatch on SQL Query in VBA
I am trying to do an SQL query in VBA to retun a specific case number. Whenever I execute the query, it returns an error of "Data Type Mismatch in Criteria Expression". I am passing the query an ...
3
votes
0answers
27 views
How to expose a class in a document-level add-in?
This is a hypothetical situation.
I would like to find out if it's possible to expose a C# class to VBA in a document-level add-in.
Here's an SSCCE:
In VS PRO 2012 I have started a new project, ...
0
votes
0answers
13 views
When publishing Excel workbook to Sharepoint, how do I turn off 'Open with Excel in the Browser' option?
When I do this manually I click File > Save & Send > Save to Sharepoint > Save as. I then manually uncheck the 'Open with Excel in the Browser' check box.
I have begun automating the report ...
0
votes
1answer
22 views
Why is this use of the “Dir” function not working as I intended?
I'm trying to place the names of all of the filenames in a folder into a list on excel, so that there is one filename per cell.
However, using the code below, it writes in the number of files in the ...
0
votes
1answer
22 views
Outlook VBA Programming
Im trying to loop through attachments. IF format of any attachment is PDF or doc or docx then prompt vbYesNo
For some reason its not working :(
Private Sub Application_ItemSend(ByVal Item As Object, ...
1
vote
1answer
25 views
error when trying to execute a macro in one workbook from another workbook
I have a multitude of reports I refresh and publish each day, and I'm trying to write a macro in a separate spreadsheet that will open each of these reports, and run the 'Refresh' macro in each ...
0
votes
0answers
21 views
Plotting multiple named arrays as single series
I am trying to create a radial grid on a dynamic plot for viewing polar data. I can create this using six circles and 12 equally spaced radial lines that extend from the inner circle to the outermost ...
1
vote
2answers
45 views
Using a global var in an SQL query
I have an access project in wich I use a global variable across all the forms to show what user is logged in.
Public activeUser As String
On one of the forms I want show data depending on who is ...
0
votes
1answer
21 views
Can anyone suggest a good Excel VBA book [on hold]
I need to get to grips with the programming Excel. Can anyone suggest a couple of good books. I have a background in programming so I do not need a complete beginners guide.
0
votes
0answers
23 views
How to change the width of data validation drop down list in excel
I have data validation in some cell say A1,
1st Problem:
Some times the drop down list width becomes very wide with no reason
how to fix the list width here
2nd Problem:
In some other drop down ...
0
votes
1answer
29 views
Excel macro help for stock updatess
I have a macro which retrieve data from the website. In the first column of excel I have product code, after hitting the process button macro opens the website and search the product codes on to the ...
1
vote
1answer
17 views
Varient data type changes value 0 to empty or blank
I am passing value 0 in the below code
Dim searchtext As Varient
Public Sub xyz_page_load()
searchtext = 0
If searchtext = "" Or searchtext = Empty Then
Debug.Print "Error" 'this line should ...
2
votes
2answers
42 views
Easily switch between single and double precision
To switch between single and double precision in C we use something like:
#ifdef USE_DOUBLE
typedef double data_t;
#else
typedef float data_t;
#endif
Is there an easy way to perform the same thing ...