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.

learn more… | top users | synonyms

0
votes
1answer
196 views

Very slow execution of Excel 2016 VBA codes

I'm having a case of slow vba code execution. I find it hard to believe because I have a quad-core Core i7 processor operating at 2.6 GHz. In my workbook, I have an input form on a separate sheet to ...
0
votes
2answers
19 views

I want to replace the text to the end of the line (right) only , without replacing the others text starting the same name to the left part

I want to replace the text to the end of the line (right) only , without replacing the others text starting the same name to the left part. Consider this line: Replace1 in the text Replace1. I want ...
0
votes
1answer
36 views

excel selected cell in named ranged column

I thought this would be a simple answers but cant find it anywhere I have a macro based on the selected cell which is run in a right click context menu. I need to get the column number based on ...
2
votes
2answers
124 views

Linking a chart series' name to a range through VBA

I would like to link the chart series' name to a range on my worksheet, but not the whole string in that range. For example, instead of linking the name to a cell that contains "201601", I want the ...
1
vote
1answer
134 views

Create Bat File With Excel Data with VBA

I took some research from google Sub ExportRangetoFile() Dim wb As Workbook Dim saveFile As String Dim WorkRng As Range Set WorkRng = Sheets("Match").Range("K:K") Application....
0
votes
1answer
51 views

how to convert table to one column (show ONLY what i mentioned in table shopping list)

I have a table of shopping list that look like that example: (a1) vegetables (b1) amount (c1) fruits (d1) amount (e1)drinks (f1) amount and in row 2 and so on there is the list. so I want to see ...
0
votes
1answer
25 views

Excel - VBA: Auto Print multiple File Only 1sheet

i have a code to Auto print multiple File but this code print every sheet in File now i have 44 file in every File is 3 Sheet [Sheet1,Sheet2,Sheet3] i want to print only Sheet1 Sub auto_print() ' ...
0
votes
3answers
33 views

Determine exact properties applied by Button

Let's say I click a button in excel like comma formatting, is there a way to determine the exact styles it applies to the selection? I'm trying to avoid browsing the tree manually. Alternatively if ...
1
vote
1answer
32 views

VBA to move a cell content and delete the row - introduce error checking

I have written the following lines of code in VBA and I'm new to VBA. Sub move_content() 'declaration Dim srcrow, srccol, destrow, destcol As Integer Dim lastrow As Long 'intialization ...
2
votes
1answer
34 views

Nested IF statement only working when outside IF changes

I'm trying my hand at VBA. I have a statement that says: Sub PM() Set rn = ActiveWindow.VisibleRange.Cells(1, 1) Application.ScreenUpdating = False 'If Not Intersect(Target, Range("C27")) Is ...
0
votes
1answer
18 views

How can i combine multiple IF's on the same line

i have the following code that does not work: If Range("I69") > 0 and If Range("I70") > 0 Then DoSomeCalc's end if how can i make this function properly?
0
votes
0answers
20 views

How do I create a VBA macro that copies non-duplicate data from sheet2 to sheet1 in Excel? [duplicate]

I have two sheets in an Excel workbook: Master and NewData. I want to copy rows from NewData to Master only if it's not something already in Master. ("New data", get it? ;)) (Columns A:J would be the ...
0
votes
1answer
35 views

Excel VBA insert records from database in correct order

I'm trying to get records from a database and fill them into excel. This is how I get the data and fill it (note: the query is simplified, I can't just ORDER BY DESC): Sub FillPersons(ByRef ...
0
votes
0answers
74 views

Conditionally apply formatting (table style options) to word-table last row

In word 2016 I have a document template with a predefined table-style. When I apply this table style I can choose to e.g. apply 'total row' formatting. I would like to apply total row formatting via ...
1
vote
1answer
71 views

Publisher Macro run in all documents

I wrote a macro in Publisher and have added it to my Quick Access Bar. Unfortunately, the macro only runs in the document that created it. In all other documents, the button does nothing. Is there a ...
0
votes
2answers
96 views

Excel 2013, combine CountIF + VLookup

I have the following issue, and I need advice on which formulas to use or if I'm better off trying some VBA codes? (I have no idea!): I'm working at an Excel 2013 sheet which has the following data (...
1
vote
0answers
114 views

VBA code to select by a cell value and date range to move data from one sheet to another

I am having trouble getting a VBA code that I have adapted for my program to run. There are things in it that I don't understand and I don't know how to fix. I am trying to filter data from a "Sales" ...
0
votes
1answer
39 views

Delete specific named TextBox in Powerpoint using VBA

I have a PowerPoint presentation which have about 105 slides. On each slide, there is a Text Box named TextBox4. I want to delete all these text boxes. I have tried some VBA code by Google Search. ...
1
vote
2answers
282 views

Naming an Object in Excel VBA so it can be selected once it's copied to another sheet/workbook

I'm amateurishly putting together macro/VBA in Excel. It involves copying an image, which is of a legend in a different language, from Source.xlsx, and pasting it into Destination.xlsx. The image is ...
1
vote
1answer
140 views

Using VBA code to move data from an invoice to a sales summary page

I am creating a database for a friend of mine. She owns a small shop where people can purchase artisan pieces. I have created a Artisan list, and inventory list. on 2 sheets then I have an invoice ...
0
votes
1answer
25 views

Can not calculate on decimal number

Please click on the link to see my image Here is my code. I don't understand why its always false only decimal number. What should I do? Sub calcu() Dim a As Integer Dim b As Integer Dim c As ...
0
votes
1answer
44 views

How to replace following script to search for values and not strings?

I have the following macro which iterates though each cell in a specified column. If the cell contains a value of the string #VALUE!, it is replaced by the average of 2 cells above and below it (which ...
0
votes
1answer
265 views

Excel VBA Code to move data from 4 specific cells to another worksheet in the next available row [closed]

I have been learning about VBA code but this has me stuck. I am using Excel-2013. I have 4 cells in my "Invoice" sheet (Cells E3, C3, E36, and E34) that I want to transfer to my "Method of Payment" ...
1
vote
0answers
24 views

Aggregating Repeating Labels in Excel Sheet into Proper Table

I have an excel file with two columns: the first contains a repeating sequence of 14 labels, while the second contains the text values associated with those labels. What I'd like to do is aggregate ...
1
vote
1answer
34 views

Excel document open by two users. Update the data

I have an Excel document that is used by two users. Each inputs different data to the same document (two open instances of the same document). Can I update the data via VBA if I press a button? So ...
0
votes
4answers
53 views

How can I tell if sheet a exists in a workbook?

I have the following code that's not working as expected: If Sheets("a") <> "" Then MsgBox ("sheet a exists") How can I tell if sheet a exists in the workbook?
0
votes
0answers
163 views

VBA/Macros Runtime Error Fix (Run-time error '13': Type mismatch)

Run-time error '13': Type mismatch Is the error code. A previous person made a macros which hides all blank rows and assigned it to a button. Recently someone made some changes which affected many ...
0
votes
2answers
164 views

What is largest value (number) that I can store in an Excel VBA variable?

I am using Microsoft Office Excel 2007. Suppose I have the number 12500000000000. Dim value1 as long value1 = CLng(copyrng2.value) 'where copyrng2 is a range (cell) variable containing ...
0
votes
1answer
32 views

Creating a Macro to sort items by date entered (results triggered from formula)

I have Sheet 1 where I am entering in new data on a worksheet, and on my Reference sheet I am pulling the same values from sheet 1 in so that I can sort them by time entered. My goal is to have a ...
1
vote
1answer
35 views

Equivalent to Excel 2013's 'BeforeSave' for Excel 2010?

I am trying to have a housekeeping macro run when an Excel sheet is saved, but I can only find reference to this: https://msdn.microsoft.com/en-us/library/office/ff840057.aspx for Excel 2013. Does ...
0
votes
1answer
234 views

Excel VBA - Getting “Object Required” Error When Stating Range Is Not Null

Below is my code where I'm getting the error. I've marked the line that the error occurs on in bold (i.e. ** at the beginning and end of the line **). The specific part of the code I'm receiving ...
0
votes
1answer
247 views

Error: The Macro May Not Be Available In This Workbook Or All Macros May Be Disabled

I'm trying to adopt the solution from this post & I've modified the macro slightly (I only need to add on button click) so that it's now Sub AdjustValue() Dim btnName As String Dim ...
0
votes
0answers
74 views

Cleaning up data fetched from Google Spreadsheet to Excel

I've been trying to synchronize and build a local database with Excel data. I need to build the database and program to create user accounts, manage the packages, track and log the status of the ...
3
votes
1answer
125 views

Calculating partial values for use in a weighted average

I have a spreadsheet with the following information: Column A contains a list of courses (eg Course 1, Course 2, etc) Column B contains the number of credits available to each course Column C ...
0
votes
1answer
52 views

'On Error Resume Next' not working

I have one procedure in excel vba code. In this I use 'ON ERROR ....' syntax. Procedure starts with ON ERROR RESUME NEXT to skips all error. But at some point I want to change that status from ON ...
0
votes
1answer
85 views

XML data from one Excel cell to new XML file [closed]

In A1, A2, A3... A16000 I have the entire context of a XML in one cell. Example: The entire XML for one invoice is in A1, the next invoice in A2 and so on. How could I save the context of each ...
0
votes
2answers
219 views

Copy multiple Excel workbooks into one workbook

I am trying to copy multiple Excel workbooks into a single workbook with each of the copied workbooks to have their own Tab. I do not know how to use VB, so I have tried many VB scripts I found ...
0
votes
0answers
71 views

Copying data from a mixture of protected and unprotected workbooks in Excel

I've been given 16 productivity-tracking spreadsheets from a team, and tasked with pulling the numbers from all the sheets into one, for a 'team average' type deal. Two of the 16 workbooks are ...
0
votes
1answer
39 views

How to display unique numerical values from different columns into a single cell (separated by commas)

I have a unique problem I have been trying to tackle with no avail. I have scoured through the internet but only found partial solutions and not a complete solution. I am looking for a function (or ...
2
votes
1answer
53 views

Excel VBA Run-time error '1004': Applicated defined or object-defined error - Need code assistance

This is the code that I am having an error on in Excel: Sub Start_EndDelayInMonth() With Sheets("Analysis Worksheet") Dim i As Long Dim LastRow As Long LastRow = Range("N" & Rows.Count).End(xlUp)....
0
votes
0answers
44 views

Creating a dropdown submenu in PowerPoint

I would like to know if it's possible to create a dropdown submenu in PowerPoint like the one for inserting a WordArt: If it's possible can you share with me some documentation about this?
2
votes
1answer
73 views

VBA EXcel - I am getting an error (400) if using error trap getting no object/application defined error

My excel sheet has these data, 7 columns sl.no | bed | 2| 4| 3|4|3| some times column no 7 is empty, and then only I'm getting error And my code Sub sup_cal_area_sft() Dim lru, plru As Long Dim ...
0
votes
1answer
65 views

Excel formula disappears when saving as .xls

I have a long formula in one of my cells. It is: =IF(K11=1,MATCH(C66,valv1,-1),IF(K11=2,MATCH(C66,valv2,-1),IF(K11=3,MATCH(C66,valv3,-1),IF(K11=4,MATCH(C66,valv4,-1),IF(K11=5,MATCH(C66,valv5,-1),IF(...
0
votes
1answer
52 views

Excel Macro to draw xyscatter plot out VBA

I am trying to create a xy plot where the x values is the time axis (column A) and the y values are in the other columns. (in the example only C and D) When I try my code from below, I get a graph ...
-1
votes
2answers
47 views

how can i make my macro toggle a sheets visibility/hide?

i have the following code that i want to toggle a sheet being visible or being hidden: Sub toggle() If Sheets("Navigation (2)").Visible = True Then ActiveWindow.SelectedSheets.Visible = False ...
0
votes
1answer
188 views

Checkout/in Excel Workbooks from SharePoint with VBA

I have found several articles and past questions in SO that help with this, but I have added a twist. I found a way to map a network drive on my PC to the SharePoint folders. If I open a workbook that ...
0
votes
1answer
43 views

VBA warning when cells selected are not equal to 5 and contiguous

My Vb macro does the following: I select 5 contiguous cells, run my macro and I get 5 static random numbers between 1 and 50; It works perfectly; I need a warning when the selected cells are not ...
2
votes
1answer
270 views

How to run a macro on a shared mailbox in Outlook 2013

I am working with my own mailbox, but also with a shared mailbox. I have a macro to automatically save attachments in e-mails which I receive, but this works only for my own mailbox and not for the ...
-1
votes
1answer
64 views

Formatting any cell referenced in a Formula [closed]

I have two sheets, one with formulas pulling data from the second. I need to create a macro or some conditional format to highlight the cell green if the data was pulled from the second sheet. sheet ...
3
votes
2answers
84 views

How to apply a macro/vba formula to more than just one cell

I have entered the follows: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$V$2" Then Range("U2") = Range("V2") * Range("O2") End If If Target.Address = "$U$2" Then ...