Newest vba Questions

Q&A for professional and enthusiast programmers

vba dynamically created checkboxes onclick events

I have a list of checkboxes on a userform created from a list on an Excel sheet. I want to have an additional checkbox that when checked, is testing the caption value of all the checkboxes in the list....

What is wrong with this Excel Chart x-axis assignment?

I am using VBA to update the series' for several charts. I have some charts that show 3 series. I can update those fine, but when I try to update the x-axis I get errors. Here is what I've got so far: ...

How to adapt this code to insert saveas dialog box

I have the code below to save one worksheet of my workbook, I would like to change some things, one of the things I am trying to change and I am having some issues with this is to add a SaveAsBox in ...

VBA code to download file from internet works only sometimes?

First off, this is the sort of website I am trying to download files from (via clicking on "Download Data" with the CSV option on). The problematic code (I think; it's hard to tell, partially because ...

How to loop function through list of aurguments in VBA

I am looking to make this VBA function more dynamic and handle a list of inputs rather than a single static argument. The function I have is working correctly for a single hard coded file, I would ...

TExt to column data selection.

Can anyone please create a simple vba code that can perform a text to column using comma as delimiter on selected names in a column. If the coding works no matter which column the data is in and ...

VBA Excel Paste Special

Why does the following not paste as values? Sheet1, B10 has a formula, it pastes in Sheet2 as a 0. Any help with the macro below? Worksheets("Sheet1").Range("B10").Copy Worksheets("Sheet2").Range("...

VBA - Copy multiple columns using index/match to fit multiple criteria

I'm pretty new to VBA. I have two sheets. The first is an old large sheet with outdated information and the second contains a subset of the first one with updated data. Here is a (truncated) example ...

VBA code to send emails

Hi i created this VBA code to auto send emails from excel using macros. what can i do to send one email with data in different rows? as now the code is taking individual rows and and sending email ...

Get Word bookmark index to replace image inside bookmark from Excel

This question is related with a previous one. I have an open Word document with a bunch of bookmarks, each with an inline image of an Excel table previously exported from Excel. Now, I need to ...

Looping though only selected sheets to proceed several steps

I have an Excel file which contains several sheets where I have to cut-copy from one column to another. When I use the code on one specific sheet it works perfectly, yet while I've already tried to ...

Issue in XLSB reading via C# using Interop

I'm getting error while trying to open XLSB file using Interop, please help me to resolve the issue. I need to use Interop for sure. Error Message : "Excel cannot open the file 'Results_Preprod....

Excel VBA - If value exists > x, add to sum, with a caveat

I was assisted last week with the below code to search a table for time values greater than 91 minutes, ignore the first instance, then sum subsequent instances in a running total. I need to adjust ...

Checking PC Date region in Excel/VBA

Is there any VBA function that lets me check a PC date format (regional setting). This is set within the Control Panel -> Region and Language. Michael

VBS. Add header to specific Excel document

I'm trying to amend the below code so it adds the headers to specific Excel document and closes it once it has added the headers. The script keeps dying on row two and being new to vba I'm not sure ...

VBA .formula= If() with Cell(x, y) as dynamic reference

I'm trying hard to fix this since some time but I can't on my own apparently. ThisWorkbook.Sheets("GesamteListe").Cells(X, 18).Formula = _ "=If(" & Cells(X, 16) & " " = " " &...

Exiting a loop executing a function then reentering the loop

I have a loop that goes through each worksheet in any workbook in a directory and executes certain code. I need to adjust that code so that after its done with each worksheet it jumps to a specific ...

VBscript to save excel sheet as pdf

<html><head> <script language="vbscript" type="text/vbscript"> Sub SaveExcelAsPDF () 'Save Excel file as a PDF 'Initialise Dim objExcel, objWorkbook Set objExcel = CreateObject("...

Find sub-string and return it plus previous 17 characters

I want to be able to search a text file in Windows for a sting ("A R") and return the every instance of the string plus the previous 17 characters. The characters contain numbers, dashes, and slashes. ...

Finding last used row in a table then adding data to the remaining rows below

I've been googling this one for a while now with no success - I have a table with around 850 rows and in columns 8 to 13 I need to find the last used row, and then add data to the remaining empty rows ...

Excel VBA: How to use objects defined in a previous module in a new module without defining them again [duplicate]

I have previously defined Report_wb in an module Obtain_Data, and now I am writing a new module Module1. I want to use the object Report_wb without defining it again. Is there any way to do that? ...

VBA Moving items to a specified subfolder inside outlook based on ReceivedTime

I am trying to (see title) however the code runs with no error messages but no emails are moved. This leads me to belief the necessary IF condition is never being met? However i could be wrong. Please ...

let MS-Word vba ActiveDocument.Paragraphs(2).Select select paragraph 1 only?

I want to add many hyperlinks via VBA for my MS-Word file, for 1st paragraph the hyperlink is "./index/1.doc", 2nd paragraph is "./index/2.doc", and so on. The simpilfied procedure is 1)select one ...

How to saveas a specific worksheet in a workbook with multiples worksheets

I have one workbook with multiples worksheets and multiples macros assigned to buttons. Well, one of these buttons is responsible to create a new worksheet named "Savings" and saveas this worksheet ...

VBA Excel copying and pasting a Template

Background story: I'm doing a little project that is for my little association to help people to have a clear and understandable accounting system. I'm a total novice in VBA and I have been looking ...

Check cell values in two different sheets

I have two sheets in an excel file namely bank_form and Pay_slip. I am trying to write a vba to check whether value/text in cell B5 of sheet Pay_slip is equal to value/text in cell B8 of sheet ...

Excel saving to My Documents and not file location [on hold]

My Excel keeps saving to My Documents and not file location located on the shared drive. The file is a shared document with macros. Can anyone help me please? Not sure why its defaulting to my ...

simple VBA regarding data extraction & table formation

here is a small problem I'm struggling with... so basically I have scrapped from a table from a website and it has two columns which is not that useful to use as a data. I'm trying to rearrange the ...

Create Excel Alert/popup if certain condition applys

I would like to create an Excel Alert/popup if in every row i have after 7 cells contents the 8th cell is not a certain word. Every row 8 cell count if certain WORD is not in one cell, Alert. For ...

Insert Specified Number of Rows on Specified Date Column Change

Before you flag this, please note that I need to amend Existing code to be able to fit multiple cases. I have: Sub InsertRowAtChangeInValue() Dim lRow As Long For lRow = Cells(Cells.Rows....

VBA code to copy data from Excel spreadsheet into PowerPoint?

I was assigned to create an employee organization chart in PowerPoint that can be created with a VBA code that will search for data in an excel spreadsheet and then copy it into PowerPoint. For ...

How to select which PowerPoint to edit in Excel VBA?

I am building a report where users will take tables from Excel and paste them into a PowerPoint. Since I won't know what the users will name the PowerPoint, I am giving them two options. If the one ...

Does Excel for Mac support classes?

Simple question but my Google-Fu is letting me down and I don't have a Mac to test. Excel versions 2011+. Thanks.

Message box, search, copy and paste to new worksheet and repeat

This is the code I am using for my excel spreadsheet "Product Database". It works fine, I just need it to continue "looping" in a way. After I search for the product I am looking for is the message ...

Select Outlook Folder With Excel VBA

I'm trying to bypass having to select the folder I want and just tell Excel to go ahead and count the "Inbox" Sub Get_Emails() Dim OLF As Outlook.MAPIFolder Dim EmailItemCount As Long Set OLF = ...

Excel VBA - Correct VBA code for summing multiple rows

What is the correct way to code in VBA the below formula? I need to sum 5 columns in a row in the 6th column, and do this for a total of 7 rows. Range("G21").Select ActiveCell.FormulaR1C1 = "=SUM(RC[...

VBA Excel: Copy data from one cell to another when it meets condition

I have a key holding sheet at my job I'm working on. I've created a button macro to try and do the below. I want to be able to loop through a one column of information and if a cell contains data in ...

Worksheet cell custom names access value in VBA

Lets say I have a cell C1 and I define the name of it as follows below: How can I access this cell in VBA?

Remove \u00A0 character from a string

I have the following string in a cell: I want to split the string into an array which contains only the textual word (such as 'CRMNegocios') without any bullets, new lines, etc... To do it, I've ...

Assistance with excel-VBA macro - beginner

I have an excel spreadsheet I must perform lots of formatting on, on a weekly bases. I've decided to try create a VBA macro for this in order to quicken the process. I have around 8 different steps ...

Turning a string of characters into a hyperlink

I have searched a ton for an answer to this question and I can't seem to find one that is specific to my needs. I think it might be possible that I am just not understanding how hyperlinks work in VBA....

Freeze column content from drop down in Excel

Hi I am new to excel for this kinds requirements. I want to freeze the cell content (from a drop down) once a selection is made. Users should not be able to modify the entered content. Once the ...

Match-Index or Copy cell value to a specifically named range

Background: I have a calculation program that gives me temperature values of nodes at different times (time step is 30 sec and up to 120 min, number of nodes can vary up to 200'000). The program gives ...

type dismatch run time error (13) for vba

I want to do filter for the region and delete the rest of the rows that don't match the region. The sheet has no formulas in it only values and characters. This is part of the larger codes I am ...

How do open template without increasing index?

So I have a template I'm opening to get some data called Planung.xltm. My problem is that when I open it manually it's called 'Planung1'. But when I call Workbook.open(path/Planung.xltm) the index ...

How to create if condition to create excel sheets

I am trying to create a VBE Code to create a new excel worksheet. To create a new worksheet I am using the code below and is working really fine: Dim ws As Worksheet With ThisWorkbook ...

vba open workbook at url address using wildcard?

I have a workbook stored at the following url: "https://intranet.net/info/some%20info/" I have a .xlsm file which changes name slightly from time to time: Food Specials Rolling Depot Memo 1-12.xlsm ...

How can get and set value of cell contain image?

My Excel Data: Cell1 contain text and image: I want get value of Cell1 set to Cell2. I try : Cell2.Value=Cell1.Value this code only set text, can't get & set image. How can get and set value ...

Applying a UDF to each value used as a range for sumproduct

I have written a UDF in VBA that takes a parameter and a string and processes them to return a double. I would like to be able to use this formula to process a column of a table for a range in a ...

Creating/Saving PDF from URL - file not downloading correctly

I'm trying to save a URL as PDF with VBA. I'm able to get a file to download/be created, but when opening I get an error: Acrobat could not open 'file.pdf' because it is either not a supported ...
Translating... 0%