Newest 'excel-vba' Questions

Q&A for professional and enthusiast programmers

Excel VBA Code to copy chart to word without resizing it

I'm Trying to copy Charts from Excel 2016 to Word 2016 as Pictures or Enhanced Metafile but to retain the original size. When I do it manually it works perfectly, but when I do it in VBA, whilst the ...

Print/Import all web page source data using vba

I have code below which imports only part of source code into sheet. I want all source code as it is.`Sub GetSourceCode() Dim ie As Object Dim str As String Dim arr str = Sheets("sheet2").Range("I1"...

Dynamic referencing the UsedRange in VBA

I have a code that gets data from a sheet and creates a graph. In the source sheet, each column is a series, and the number of series may change. What my code does: it reads the used ranges so that ...

Excel VBA zooming range

If Target.Address = "$D$2:$F$861" Then ActiveWindow.Zoom = 100 [A5000] = "zoomed" ElseIf [A5000] = "zoomed" Then 'Otherwise set the zoom to original ActiveWindow.Zoom = 70 [A5000]...

vba: what does the pound sign (#) mean before variable [duplicate]

I am writing code to read lines from a text file and I came across this method: Dim FileNum As Integer Dim DataLine As String FileNum = FreeFile() Open "Filename" For Input As #FileNum I understand ...

Include source sheet name to an output sheet

I'm trying to consolidate multiple sheets into one sheet and add a new column for the final "Combined" sheet. The new sheet should have a column named "Source" with the sheet name from where the rows ...

How do i compare only the first 8 caracters in cells

In the macro below data in Sheet1 cells in column "X" is compared with data in column "A" on sheet2. If there is a match the entire corresponding row from sheet1 will be copied to sheet3. I need a ...

Excel VBA loop folder and check if Excel file name is equal to worksheet

I'm in need of some enlightment. I'm trying to match a folder of Excel files with some sheets in an Excel workbook. So far, I'm able to read these Excel files names and corresponding sheets and copy ...

Insertion the entire row using particular cell value using VBA

I have the problem in this format from hrs to hrs quantum rate 12:00:00 6:00:00 100 1.8 12:00:00 5:00:00 125 1.6 I want this data in given blow format like from hrs to hrs ...

Can access the sheets while macro running until i click menu button

Hi i still newbie in excel macro vba world, so i need some help with simple coding. i'm making menu with macro so by clicking it would go to the sheets and have a back to menu button but the problem ...

how can i swap two elements in an array to put them in ascending order? [duplicate]

So I have a list of random numbers in column A which is my array. I want to reorder that array by swapping elements in the array so that the list will now be in ascending order. Sub Algorithm1() Dim ...

detect cell value in different excel sheets that contains different value using vba excel

Based on the code below, I want this code to detect the word "Oranges", "Oranges1", "Oranges 2" etc but all I can do now is only to detect Oranges. It became more complicated for me when I want to ...

Save search results and return a list of addresses

I am running a search loop through a column via manual input and picking information of columns further right of the found item. I do not want to display the results immediately but at the end of the ...

Rearranging Columns in Multiple Excel Files

I have more than 100 excel files in .xlsx extension, Columns in all the files are not in order, i would like to re-arrange the Column order as per my Template and i would like to append the data from ...

VBA - how to use google form on IE.navigate with process in the background

I'm currently using the following code to open an IE instance and navigate a complete-with-answers google form link. By accessing this link, the google form is immediately answered by the "entry....

How to generate QR code for excel data?

I have data in excel style sheet. I want to generate QR code for excel data based on column(by specifying cell range). Can anyone please help me how to achieve it using VBA or C#? Sample data to be ...

VBA loop not working?

I have a workbook called Master with 2 sheets: Sheet 1 This sheet has a number value of '18' in cell I8 as shown above. Next I have my sheet 2 More on this sheet in a moment. I am trying to ...

Integrating POS data with vb excel [on hold]

i have 5 files of Point of sale data i need to integrate them. is VB excel the best method, the data is huge in the millions of lines, essential data are the bar-code ,period and value fields i ...

VBA code to generate permutation/combination [on hold]

I want to generate list of all the permutation from given alphabets. Only those permutation which meets following conditions to be displayed. - 4th letter should be "A" and 12th letter should be "B"....

IF and VLOOKUP in worksheet change macro

I have a spreadsheet, small sample below, the actual is over 100 rows. I have a worksheet change macro for when the week number is changed in B3. If Target.Address = Range("$B$3").Address Then ...

Excel VBA auto-update date when value changes from formula in different cell [on hold]

I'm trying to figure out the code needed for sheet1 to auto update the current date in C2:C70 when a value of a formula changes in a single cell of B2:B70. Example: B2 formula =COUNTIF('Sheet3'!B:F,...

Calling a function via Workbook_SheetFollowHyperlink() VBA causes procedure declaration error

I am creating a new worksheet via VB which also contains hyperlinks to an online tool. The tool is only accessible via SSO. Thus, I'm unable to open the link and download information (error message, ...

VBA Copy only non blank cells

does anyone one how to instead of static range: '~~> Copy the range wsI.Range("A1:K50").Copy To change it to dynamic where A1:A50 is calculated depending on non-blank cells. So if Sheet1 ...

How to export data from ListView to Excel and PDF (VBA)

I have data in a ListView and would like to export this data with column headers to a new Excel file and a PDF file. The LV is defined as follows: 'listview: | # | Col1 | Col2 | Col3 | ... ...

Compare excel sheet data on basis of 2 columns and combine them? [on hold]

I have 2 excel sheets sheet1 have column UPC and status price and cost while sheet2 have UPC and price , cost and now i want to compare the sheet with sheet1 UPC unique in sheet2 and sheet1 status ...

VBA- Reset header for each section in word document

We have trouble when create word by VBA macro. In my document, we has many sections and we need to reset header for each section. In section 1, we add image 1. In section 2, we add image 2. But ...

colour formatting of excel sheet [on hold]

On my excel sheet i have have various numbers and i want the prime numbers to highlighted how do i do this. I was doing it manually by selecting each cell and highlighting it but there should be a ...

Excel VBA Overflow error when trying to run SQL server stored proc with Int parameter

I have an OrderID of 32777 declared as Long data type in excel. Im trying to pass it to a stored procedure with the following line of code: RunStoredProcedure "dbo.updateinventory", CLng(OrderID), "...

Copy cell value if length is < 10 into the last string of cell value above VBA

I've imported a text file into excel what happens is some texts had break into the next line i.e ColumnA -------------- 1313 Disneyland Dr, Anaheim, CA 92802 , USA '<---Copy/Cut cell value into ...

Getting VBA to click a button on an addin toolbar… CommandBars?

I have live data that needs to be updated every hour in excel, fed through the Reuters addin. This would usually be automatic but because I am feeding through a different kind of data, it will only be ...

VBA By ref error and naming rows

Im starting to get really frustrated. Sometimes it work and sometimes i just get error ByRef Argument type mismatch. what i also cant get my head around is a problem where im trying to name rows in ...

Subtract 2 cells from each and place the value in another cell which is non editable.

I have one worksheet which can be entered by customer. For example, column c value should come from column B - Column A. Whenever the user enters the value in both A and B columns, it should ...

Vba Lookup value on sheet x if value like or similar to?

I have a workbook with 2 sheets. Sheet1: Column B Column C Column D Column E Dairy Crest Ltd Milk Farm Tuna Family Guiness Sheet 2: Column A ...

How to import data from multiple pages?

I have a small piece of code that lists links in a site. Sub ListLinks() 'Set a reference to microsoft Internet Controls Dim IeApp As InternetExplorer Dim sURL As String Dim IeDoc As Object Dim i As ...

What is a better database connection to use for SQL Server?

Coding in a vba environment, I'm using the ADODB recordset scheme in inserting rows to my database server. It takes me a lot of time to insert many lines on casual inserting per data. Is there a ...

Finding “GEO ID” for gathering website data [on hold]

I'm attempting to gather information from a website which provides data from various regions. My problem: Each region has it's own "geo-id" and I can't find a list of them to aid me in my queries. ...

Excel VBA - Using the range function within a range function

There are 2 things to note here. The first: I am using a For loop to step through each row. The second: I don't know which is the last column with data in each row and hence I am trying to use the ...

VBA formula does not work properly

Hello I want to implement a formula in my VBA code. It should check if all values in a column are the same. Dim intBB2 As Integer Dim LastRow As Long Dim ISINcheck As String ISINcheck = ...

How to add an error message in a function subroutines on VBA

I am really a freshman to study the VBA. I am confused about how to add an error message in a function subroutines. Here is my problem, when I finished identify a function, how can I add an error ...

Is there a way to upload multiple configurations at once to a test case in alm using vba/macro?

I have situation where-in I need to add multiple configurations to test cases in HP-ALM(Application Lifecycle Management). Adding 100s of configurations manually is mundane task. Is there a way to ...

How to auto fill from one value in a column to another column with VBA in Excel

I've got some work at the office that requires a macro that will autofill from one value in a column to another in another column. The trick is the values can occur at any cell in the column they are ...

Loop through the set of values in Excel

capture 1 is constant value for country and city Capture 2 is the list of values to loop through capture 3 is the output file needed . please let me know how to achieve the same through VBA in ...

VBA - Add item to combobox from dynamically created listview

I need load ComboBox3 with items from ListView3 that is dynamicaly changed by value in ComboBox1. Is it possible to do something like this? Private Sub ComboBox1_Change() Call filterlist 'This line ...

VBA: 1 cell to master

I need thousands of excel (2016) sheets indexed based on a single cell value. The workbooks only have 1 worksheet, and the data always exists in cell D2. I'd like D2 copied to a master file in the ...

Sorting files in a folder using VBA

I have a code that reads all the files in a folder, paste the file names in a worksheet and output the number of files into a message box. Problem: for some reason, when I run the code, it may get ...

Emailing More than 1 PDF [on hold]

I have a workbook that creates up to 3 PDFs that are emailed as attachments. unfortunately this sends an email for each PDF. Is there a way to attach the 3 PDFs to one email?

multiple VBA if statements triggering different event

Sorry i think this is pretty basic but I was wondering if somebody could tell me why only 1 of these IF statements seem to run. The 3rd IF statement for the "CASH" option works but the other 2 ...

Excel 2011 vba: How to loop rows of a column and multiply all rows by a single value?

I just wanted to get 2 columns (imagine they will host values such as numbers for x and y coordinates) and divide ALL values (aka rows) from column (let's say) A(for x) by a certain value in the ...

Excel VBA - How to transfer Textbox values into different cells of excel

Sir, I want to put a Textbox value into different cells of excel sheet. Like if i Put a value 5041354 into a Textbox of userform then on the click of a command button the same value save on excel ...

VBA to set Conditional Formatting only for cells with False value

i'm using VBA to apply conditional formatting to a sheet, setting the background color and front color if the content is "FALSE": Sub Formatting() Sheets("File").Cells.FormatConditions.Delete ...
Translating... 0%