excel-2010

excel vba macro to match cells from two different workbooks and copy and paste accordingly

柔情痞子 提交于 2019-11-30 16:13:23
i have 2 workbooks, workbook A and workbook B. Each workbook has a table. workbook A has 2 columns. All three columns are filled. product_id Machine_number and Workbook B has the same 2 columns but only one column, Product_id, is filled. The other 1 column is vacant. I need to match the cells of product_id of both workbooks. If the product_id found in workbook A matches workbook B, then the machine number of that product id should be copied from workbook A to workbook B. I have performed this using this code: Sub UpdateW2() Dim w1 As Worksheet, w2 As Worksheet Dim c As Range, FR As Long

Using COUNTIFS to count blank when cell has a formula

瘦欲@ 提交于 2019-11-30 15:57:33
I have criteria where I need to count if a column B is not blank. But I have a formula in Cell B, So if I do a simple =Countifs(B1:B10,"<>") This returns the count of the cells which have the formula but I just need the blanks when the formula does not populate anything. Try this formula [edited as per comments] To count populated cells but not "" use =COUNTIF(B:B,"*?") That counts text values, for numbers =COUNT(B:B) If you have text and numbers combine the two =COUNTIF(B:B,"*?")+COUNT(B:B) or with SUMPRODUCT - the opposite of my original suggestion =SUMPRODUCT((B:B<>"")*(B:B<>0)) 来源: https:/

Excel Looping through rows and copy cell values to another worksheet

爷,独闯天下 提交于 2019-11-30 15:47:41
问题 I am facing some difficulty in achieving the desired result for my macro . Intention : I have a list of data in sheets(input).column A (the number of rows that has value will vary and hence I created a loop that will run the macro until the activecell is blank). My macro starts from Range(A2) and stretches all the way down column A, it stops only when it hits a blank row Desired result for the macro will be to start copying the cell value in sheet(input).Range(A2) paste it to sheet(mywork)

Compare two sheets using arrays

牧云@^-^@ 提交于 2019-11-30 15:44:04
问题 My code is super slow (10+ min for each sheet) due to the quantity of data i have. I believe there may be a way to speed it up using arrays, but i am not sure how to go about it. I will try to explain the situation in detail. I have two worksheets with invoice#s, part#s and sale prices (among other info) that I am trying to compare to find differences. I've created a unique number for each line of data using a concatenation of the invoice# and the part# on both sheets. I've also sorted both

Compare two sheets using arrays

社会主义新天地 提交于 2019-11-30 15:25:06
My code is super slow (10+ min for each sheet) due to the quantity of data i have. I believe there may be a way to speed it up using arrays, but i am not sure how to go about it. I will try to explain the situation in detail. I have two worksheets with invoice#s, part#s and sale prices (among other info) that I am trying to compare to find differences. I've created a unique number for each line of data using a concatenation of the invoice# and the part# on both sheets. I've also sorted both sheets manually by that number. I'd like to find which of those unique#s are on sheet1 and not on sheet2

Excel Looping through rows and copy cell values to another worksheet

白昼怎懂夜的黑 提交于 2019-11-30 14:53:26
I am facing some difficulty in achieving the desired result for my macro . Intention : I have a list of data in sheets(input).column A (the number of rows that has value will vary and hence I created a loop that will run the macro until the activecell is blank). My macro starts from Range(A2) and stretches all the way down column A, it stops only when it hits a blank row Desired result for the macro will be to start copying the cell value in sheet(input).Range(A2) paste it to sheet(mywork).Range(B2:B6) . For example, if "Peter" was the value in cell sheet(input),range(A2) then when the marco

Put entire column (each value in column) in an array?

≯℡__Kan透↙ 提交于 2019-11-30 13:26:32
So i'm making a macro to do a bunch of things. one thing is find duplicates of cells in sheet1 from sheet2. given columnA in sheet 1, do any values in columnB on sheet2 match any of the values in columna sheet1. I know theres a remove duplicates, but I just want to mark them, not remove. I was thinking something with the filtering. I know when you filter you can select multiple criteria, so if u have a column with 20 different values in it, you can select 5 values in the filter and it will show rows with those 5 values for the particular column. So i recorded a macro of that, and checked out

How to put user defined datatype into a Dictionary

大城市里の小女人 提交于 2019-11-30 12:22:27
I'm trying to define my own data type and put it in a Dictionary as a value. VBA complains that it does not accept my data type. Any ideas about how to get this working? Option Explicit Public Type Translation german As String french As String italian As String End Type Private resource As Object Public Sub addTranslation(key As String, g As String, f As String, i As String) Dim trx As Translation trx.german = g trx.french = f trx.italian = i resource.add key, trx '<== here VBA is complaining End Sub Public Sub initResource() If resource Is Nothing Then Set resource = CreateObject("scripting

Python: Refresh PivotTables in worksheet

不问归期 提交于 2019-11-30 07:12:37
I'm building a python script that will allow me to open a Excel 2010 worksheet and print it out. I got most of the way import win32com.client office = win32com.client.Dispatch("Excel.Application") wb = office.Workbooks.Open(r"path\to\excel\file\to\print.xlsm") count = wb.Sheets.Count for i in range(count): ws = wb.Worksheets[i] pivotCount = ws.PivotTables().Count for j in range(1, pivotCount+1): #TODO code to refresh each pivot table ws.PrintOut() print "Worksheet: %s - has been sent to the printer" % (ws.Name) As you can see I'm still missing the refreshing of the pivot tables in the

Lookup using INDEX and MATCH with two criteria

核能气质少年 提交于 2019-11-30 07:01:22
问题 I am trying to achieve a basic lookup using INDEX and MATCH. My layout is: Sheet 1 NAME | SITE | DATE Sheet 2 NAME | SITE | DATE I want the 'SITE' column in Sheet 1 to automatically populate with the SITE from Sheet 2 where NAME and DATE match. What I've Tried =INDEX('Sheet2'!B:B,MATCH(A1,'Sheet2'!A:A,0)) This will successfully match NAME, but how can I incorporate an additional MATCH into the formula to match on both NAME and DATE? 回答1: I suggest the conventional solution to problems of this