excel-vba

Import tables from a webpage to excel

喜夏-厌秋 提交于 2019-12-31 07:25:09
问题 I just have an upper-intermediate level of excel and intermediate background of VBA with excel. What I want to do is to import tables from a webpage like this which appears in the link: http://www.admision.unmsm.edu.pe/res20130914/A/011/0.html That webpage shows 39 links and each link contains a table. So I would like to know an automatic way to import all these tables to excel. 回答1: This code get the data from all the links. Sub Extract_data() Dim url As String, links_count As Integer Dim i

VBA—“Error 1004: Unable to get the CurrentPage property of the PivotField class”

依然范特西╮ 提交于 2019-12-31 07:06:48
问题 I have an Excel workbook containing multiple worksheets with multiple pivot tables on each worksheet. I'm attempting to loop through every pivot table and change its 'Report Function' filter to a user-specified value selected from a List Box. All the pivot tables have the "Report Function" filter. I have around 50 pivot tables, and the code successfully changes the filters for all but around 8 pivots. Those 8 pivot tables' filters don't change; instead, the error "Error 1004: Unable to get

VBA—“Error 1004: Unable to get the CurrentPage property of the PivotField class”

久未见 提交于 2019-12-31 07:06:20
问题 I have an Excel workbook containing multiple worksheets with multiple pivot tables on each worksheet. I'm attempting to loop through every pivot table and change its 'Report Function' filter to a user-specified value selected from a List Box. All the pivot tables have the "Report Function" filter. I have around 50 pivot tables, and the code successfully changes the filters for all but around 8 pivots. Those 8 pivot tables' filters don't change; instead, the error "Error 1004: Unable to get

How can I populate an Excel cell with an image?

自古美人都是妖i 提交于 2019-12-31 06:05:06
问题 I'm trying to insert an image into an excel worksheet. The code is simply: Function AddImage(path As String, filename As String) Dim file As String file = path + "/" + filename + ".png" ActiveSheet.Range("A1").Pictures.insert(file).Select End Function but this doesn't work. When I set a watch on file I can see that it contains a valid path to an image on my hard drive. What do I need to do to populate a cell with an image? 回答1: You cannot put pictures "in" a cell, only "over" it. All pictures

Split delimited 2nd and 3rd column data into new rows

最后都变了- 提交于 2019-12-31 05:57:28
问题 I have the following table ID. ID2. String 123. 567, 986 ABC;BCD;ACD 142. 134, 654,1134 AA;BB I want it to be displayed ID ID2 String 123 567 ABC 123 986 BCD 123 ACD 142 134 AA 142 654 bb 142 1134 The values in the ID column are unique. Is there an efficient macro solution to this? I have a very huge set of data. 回答1: With only the starting, concatenated data in the active sheet and ID is in A1, run this macro. Sub split_out() Dim v As Long, vVALs As Variant, vID2s As Variant, vSTRs As

Delete entire row when a value exist in a second sheet

白昼怎懂夜的黑 提交于 2019-12-31 05:54:05
问题 I have 2 sheets: sheet1 and sheet2. I have a value in cell A3 (sheet1) which is not constant. And many files in sheets2. What I would like to do, is when the value in cell A3 (Sheet1) is the same as the value in the column A (Sheet2), it will delete the entire row where is find this value (Sheet2). This is my attempt. It doesn't work: no rows are deleted. If Worksheets("Sheet1").Range("A3").Text = Worksheets("Sheet2").Range("A:A").Text Then Dim f As String f = Worksheets("Sheet1").Range("A3")

VBA Email Loop for excel reporting

怎甘沉沦 提交于 2019-12-31 05:47:04
问题 I created a macro that would run a report for a selected indivdual and send that person an email with that package. This report is meant for roughly 20 people, but it has been tedious to run the report for each person and then send it. I was wondering if there was a way to type names in cells of the people I want to run the report to and have excel loop through each one and send that report to the selected individual and then loop to the next one. Is this possible, and if so how would I go

Pause code execution but let Excel work

最后都变了- 提交于 2019-12-31 05:46:47
问题 I am making a macro that I want to do the following things: Open a file. Wait till the file fills with data (this file uses cell formulae to download data from external database, the download takes approx 15 seconds) After 20 seconds check if everything is downloaded, if no, wait further 10 seconds (up to minute total waiting). If everything is downloaded, archive and close the file. The problem I have is stopping code execution for some time while letting the formulae update themselves in

Replace values across ALL worksheets with new value

半世苍凉 提交于 2019-12-31 05:39:20
问题 I have about 40 spreadsheets, each containing up to 300k rows x 93 columns (currently). That is about 1.1 billion data points. I need to check through each cell, and determine if the cell contains one of 8 special characters, that has been messed up on the importation of the spreadsheet. This is a task that needs to be run multiple times daily, along with a number of other steps. As such, I'm looking for a way to do this using VBA. I have the following code: Sub Hide_All_Sheets() Application

Open Word template, paste Excel data in and save

隐身守侯 提交于 2019-12-31 05:30:11
问题 I've got an Excel data range I need to be able to paste into a Word document template and save automatically using a macro from Excel. Currently when it is run, it tells me the template file is already open/locked and I have to open a read only copy for it to continue. It does create and save the word file but when I try open the saved word doc it says there are problems with the contents.. I've Googled a lot and think I'm close but if anyone can give me some pointers that would be