excel

VBA looping through sheets removing duplicates

女生的网名这么多〃 提交于 2021-01-29 19:58:53
问题 I have seen similar things, but my code that seems to be working I just want to check for improvements or what potential bugs, unintended consequences there could be for it. I have been handed spreadsheets that have ended up getting duplicate information. There are a lot of spreadsheets, some have 100 sheets inside each file. Obviously don't want to go through each sheet manually using remove duplicate information. After searching around I think I have a solution and want your opinions on it.

Excel Time Comparison and Subtraction

眉间皱痕 提交于 2021-01-29 19:57:28
问题 I am trying to do a time subtraction in excel of 30 minutes and I am running into a speed bump. So the table I have are as follows. Table "Schedule" Column 1 is day of the week (Mon-Sun) (formated as general, as this is plain text) Column 2 is start time of the shift (formated as h:mm AM/PM) Column 3 is end time of the shift (formated as h:mm AM/PM) Column 4 is duration of the shift (start to end) (formated by formula (TEXT(col3-col2,"h:mm")) ) Column 5 is paid hours (if the total hours is

Need to transpose the vertical data to horizontal format, but few cells in Vertical format can have more than 2 or 3 sub categories in Excel VBA

喜欢而已 提交于 2021-01-29 19:35:58
问题 This is BEFORE image This is AFTER Image 回答1: It is based on the assumption that your original data is still listed in the column direction. Sub test2() Dim Ws As Worksheet Dim toWs As Worksheet Dim vDB, vR() Dim rngDB As Range Dim i As Long, j As Long, n As Long Dim r As Long, c As Long, k As Long Set Ws = Sheets(1) Set toWs = Sheets(2) Set rngDB = Ws.Range("a1").CurrentRegion vDB = rngDB r = UBound(vDB, 1) c = UBound(vDB, 2) For j = 2 To c n = n + 1 'ReDim Preserve vR(1 To 4, 1 To n) ReDim

Restrict Worksheet_Change to a specified range of cells

痴心易碎 提交于 2021-01-29 19:25:30
问题 I want to record a list of live data in a separate sheet. Found this code online which works. How to do I change the range from one cell A1 to a Range A1:D30? Private Sub Worksheet_Change(ByVal Target As Range) Dim dest As Range Application.EnableAnimations = False On Error GoTo line1 If Target.Address <> "$A$1" Then GoTo line1 Set dest = Worksheets("sheet2").Cells(Rows.Count, "a").End(xlUp).Offset(1, 0) 'MsgBox dest.Address Target.Copy dest line1: Application.EnableEvents = True End Sub 回答1:

How can I combine the first two rows in 52 files as a header row and combine all the files in a single one in Power Query?

南笙酒味 提交于 2021-01-29 19:05:27
问题 I have 52 files with >50 columns. The first two rows in each of them are header rows, so they need to be combined into a single row and I want to combine them all into a single file. There are some files with a different number of columns or different column names, so if PowerQuery identifies those, I can deal with them seperately. The only way I can think of is opening each file, running a macro to combine the first two rows in all of the files, but is there a more efficient way to do that

Excel - ActiveChart.SetSourceData Source: Runtime Error '445' : Object doesn't support this action

不问归期 提交于 2021-01-29 19:01:31
问题 I have an excel workbook (v2016), where I managed to get the table name of a table based on the highest number of entries. This value (which is a name of a table) is in Sheet "Pareto" Cell B4. I'm using the following code to update a chart using an above-mentioned table name Sub GetTables() Dim YTDL1TableName As String Dim YTDL1Range As Range YTDL1TableName = Sheets("Pareto").Range("B4") Set YTDL1Range = Sheets("Pareto").Range(Sheets("Pareto").ListObjects(YTDL1TableName).Range.Address(True,

Excel - Matching entries in a column but on 2 different sheets

大憨熊 提交于 2021-01-29 18:51:01
问题 I'm trying to compare 2 columns but on 2 different sheets. One is using a query and pulling straight from a SQL database but the other is grabbing data from a query within Access. The queries are slightly different so the results aren't identical which is why i need to compare the 2 columns. Each sheet has a column (job number) and all i want to do is create another column on each excel sheet that simply says "Yes" or "No" based on whether that job number appears on the other sheet. They won

How to combine two IF statements in excel

◇◆丶佛笑我妖孽 提交于 2021-01-29 18:39:59
问题 I want to combine the following two IF statements in excel but I was not able to do so. I have tried to use IF , AND , OR statements with no luck. =IF(C98="CAB",D98*R1-F98,F98-D98*S1) =IF(C99="CAB",I99*R6-D99,F99-I99*S6) Once I want to combine the two I get you are trying to create too many arguments. Thanks, Jay 回答1: If you want to combine formulas and according to your last comment, it looks like you are trying to do something like this: =if(condition="CAD",perform Calculation,If(Condition=

Find, select, and copy row

假装没事ソ 提交于 2021-01-29 18:32:50
问题 How do I find a cell containing a certain string in a certain column, then select the entire row and copy that row using Excel vba? I am relatively new to using Excel VBA and have spent days trying to code this myself. I am working on a worksheet in which different datasets are copied into. Every data set will contain the string "page" in some cell of column A, however the row varies from dataset to dataset. I now need some vba code to first identify the cell of column A that contains the

Error with copy paste due to merged column cells

跟風遠走 提交于 2021-01-29 18:32:26
问题 I want to copy paste values from 4 columns in one worksheet into 4 columns of another worksheet depending on whether the values in a single column are null or not. Following is my code: Private Sub CommandButton1_Click() Dim lastrow As Long, erow As Long lastrow = Worksheets("jun").Cells(Rows.Count, 1).End(xlUp).Row erow = 20 For i = 8 To lastrow If Worksheets("jun").Cells(i, 16).Value <> "" Then Worksheets("jun").Cells(i, 16).Copy Worksheets("jun").Paste Destination:=Worksheets("test").Cells