worksheet

excel vba compare & copy worksheets from 2 excel files

非 Y 不嫁゛ 提交于 2019-12-08 14:24:06
问题 i've workbook 1 with 100 worksheets. i've workbook 2 with 200 worksheets. i need to perform 2 tasks: For those existing worksheets(same worksheet name in both books), i want to delete book 1 worksheet content (column A-Z) and copy content (column A-Z) from book 2 to book 1. For those missing worksheets in workbook 1, i want to copy the entire worksheet from book 2 to book 1. pls advise if there are any existing online vba, thanks. 回答1: First of all you need to loop through all your worksheets

VBA : Merge certain worksheets in different workbooks into one workbook

做~自己de王妃 提交于 2019-12-08 13:57:36
问题 I encounter a problem that I can’t solve. Here it is : I want to copy certain worksheets contained in certain workbooks and paste it all in a single new workbook. More specifically, I have a Folder called « Fonds » which contain 20 workbooks, each one having the same structure : They are all called « 01082014_FONDS », 01082014 changing for each workbook and being a day of the month. In each of those workbooks, there is a worksheet called « Portfolio » and another one called « Disponibilités »

Fastest way to drop a DataSet into a worksheet

两盒软妹~` 提交于 2019-12-08 08:56:48
问题 A rather higeisch dataset with 16000 x 12 entries needs to be dumped into a worksheet. I use the following function now: for (int r = 0; r < dt.Rows.Count; ++r) { for (int c = 0; c < dt.Columns.Count; ++c) { worksheet.Cells[c + 1][r + 1] = dt.Rows[r][c].ToString(); } } I rediced the example to the center piece Here is what i implemented after reading the suggestion from Dave Zych. This works great. private static void AppendWorkSheet(Excel.Workbook workbook, DataSet data, String tableName) {

How to access a worksheet property using a variable?

隐身守侯 提交于 2019-12-08 07:37:57
问题 Situation: Whilst writing an answer for a question on SO I got stuck with the following: Question: How to pass a worksheet property as a variable? For example, I was looking at worksheet protection properties and wanted to assign them via a variable e.g. with psuedo code: myVar = ProtectDrawingObjects If Worksheets("Sheet1").myVar = True Then ...... What I have tried: 1) In the first instance I searched for a set of enums to use but to no avail. I found references in Visual Basic to enums but

What is the analogue to Excel Interop's Worksheet.UsedRange.Rows in Spreadsheet Light?

£可爱£侵袭症+ 提交于 2019-12-07 22:36:32
问题 Using Excel Interop, you can get the count of rows in use by a sheet like so: _xlSheet.UsedRange.Rows (where "_xlSheet" is an Excel.Worksheet). What is the equivalent in Spreadsheet Light? You can add a worksheet like so: var sl = new SLDocument(); . . . sl.AddWorksheet("SheetsToTheWind"); ...but how can you then access that worksheet to interrogate it for its used row count? 回答1: After adding the worksheet it is active as well. That means that you can get the WorksheetStatistics from the

Comparing columns in two different excel sheets and workbooks, then posting the matching value into another column

强颜欢笑 提交于 2019-12-07 03:59:02
问题 I'm having lots of trouble trying to figure out this macro, so right now I'm using 2 sheets in a workbook; I'd like to use two different workbooks but that isn't as important as the issue. To explain, Sheet1 column E is the id number and in Sheet2 column A is the id number, now if any value in Sheet1 E matches a value in column A in Sheet2, I need the macro to copy the corresponding cell from Sheet 2 column D. So essentially if E5 (from sheet 1) matched A1 in Sheet2, I would need the macro to

Adding Sheet Names to Array in Excel VBA

大憨熊 提交于 2019-12-06 13:45:52
I am trying to add sheet names into an array in Excel VBA using the code below. It is only picking up one value (always the last worksheet name). For example, if I have 2 sheets: List1 and List2, it only picks up List2 and shows a blank value for the first sheet. If I add 4, it only shows the 4th, and so on. I'm not sure why I'm getting blank values. Dim curSheet As Worksheet Dim ArraySheets() As String Dim x As Variant For Each curSheet In ActiveWorkbook.Worksheets If curSheet.Name Like "*List*" Then ReDim ArraySheets(x) ArraySheets(x) = curSheet.Name x = x + 1 End If Next curSheet You should

calling excel worksheet function from excel cell

佐手、 提交于 2019-12-06 03:01:04
问题 I have a set of user defined vba functions that sit in an excel module, which are then called from an excel spreadsheet... everything has worked fine at this point. I've been asked to move the vba from the module to the worksheet's code page. When I did this, I've found I can't call any of the functions from cells on the worksheet... the names simply don't show as existing. Is there a way to call worksheet functions from an excel cell? Also, is there any problem calling a worksheet function

Protect Excel Worksheet For Read Only But Enable External Data Refresh

那年仲夏 提交于 2019-12-06 02:49:23
问题 I have an Excel 2010 workbook. One worksheet imports data from an external data connection (SQL query). I have also added additional columns to the worksheet to perform calculations on the data and to massage it a bit. The worksheet forms the backbone of the raw data used in the other worksheets. I'd like to protect the worksheet to make it read-only (allowing sort, filter, pivot table usage). I know how to do this with the protect worksheet feature. But when the worksheet is protected, I can

Comparing columns in two different excel sheets and workbooks, then posting the matching value into another column

那年仲夏 提交于 2019-12-05 06:51:32
I'm having lots of trouble trying to figure out this macro, so right now I'm using 2 sheets in a workbook; I'd like to use two different workbooks but that isn't as important as the issue. To explain, Sheet1 column E is the id number and in Sheet2 column A is the id number, now if any value in Sheet1 E matches a value in column A in Sheet2, I need the macro to copy the corresponding cell from Sheet 2 column D. So essentially if E5 (from sheet 1) matched A1 in Sheet2, I would need the macro to output Sheet2's D1 to Sheet1's F5. It would also be nice to delete the values of Sheet1 column F if