excel-vba

If values of two sheets match then add new sheet

落爺英雄遲暮 提交于 2020-01-04 14:10:54
问题 I have two sheets that have two columns with equal values, I want my script when the two values match create a new sheet with the name of value in a second column of the second sheet adjacent to the value found. The script below stops at the first matching, I wish that the process continues for all possible matches. Public Sub try() Dim lastRow As Long Dim i As Long, j As Long, b As Long, Fente As String, newente As Worksheet With Worksheets("totale") lastRow = .Cells(.Rows.Count, "A").End

Match Any Word Inside Cell With Any Word In Range of Cells

北战南征 提交于 2020-01-04 14:06:55
问题 I have a list of phrases. I would like to check if any new terms match that list partially by word. I'm looking for a code to implement fuzzy matching on the list to return the cell that has a close match. Example Data: Phrases,Terms real term,new words great work,new term check phrase,more phrase example here,great alpha phrase random,beta new Desired Output: Phrases,Term,Match real term,new words,No match great work,new term,real term check phrase,more phrase,check phrase/phrase random

How to Check for duplicates in 2 columns and copy the entire row into another sheet?

放肆的年华 提交于 2020-01-04 13:48:58
问题 I want to check for the duplicates in columns A & F if either of that contains a duplicate, I need the macro to copy the entire row into another file in the same workbook. Please someone help me with this. Below is the macro that I have written to check for duplicates in A and then copy the entire row into new sheet named "dup" Option Explicit Sub FindCpy() Dim lw As Long Dim i As Integer Dim sh As Worksheet Set sh = Sheets("Dup") lw = Range("A" & Rows.Count).End(xlUp).Row For i = 1 To lw

How to Check for duplicates in 2 columns and copy the entire row into another sheet?

╄→尐↘猪︶ㄣ 提交于 2020-01-04 13:48:01
问题 I want to check for the duplicates in columns A & F if either of that contains a duplicate, I need the macro to copy the entire row into another file in the same workbook. Please someone help me with this. Below is the macro that I have written to check for duplicates in A and then copy the entire row into new sheet named "dup" Option Explicit Sub FindCpy() Dim lw As Long Dim i As Integer Dim sh As Worksheet Set sh = Sheets("Dup") lw = Range("A" & Rows.Count).End(xlUp).Row For i = 1 To lw

Retaining clipboard content during code execution

不问归期 提交于 2020-01-04 13:37:06
问题 This seems like it should be a simple problem but I've been unable to solve it. I have a program I'm writing where the user is babied through these steps: Step 1: Go to another spreadsheet and copy the content Step 2: Come back to my spreadsheet and press a button to paste that content When they press my button it needs to unlock the current sheet and paste the data without any of the formatting. This is what I have: ActiveWorkbook.ActiveSheet.Unprotect Range("A1").Select Selection

Excel: Change background color of a cell to RGB color written in that cell

爷,独闯天下 提交于 2020-01-04 13:32:03
问题 I have this code which shows rgb color of target cell: Function getRGB(RefCell) Dim mystr As String Application.Volatile mystr = Right("000000" & Hex(RefCell.Interior.Color), 6) getRGB = Application.Hex2Dec(Right(mystr, 2)) & ", " & _ Application.Hex2Dec(Mid(mystr, 3, 2)) & ", " & _ Application.Hex2Dec(Left(mystr, 2)) End Function I need that this code instead of showing off rgb of other cell, would change background color of its own cell. Maybe anyone know how to do it? 回答1: The MSDN KB says

Excel: Change background color of a cell to RGB color written in that cell

佐手、 提交于 2020-01-04 13:31:27
问题 I have this code which shows rgb color of target cell: Function getRGB(RefCell) Dim mystr As String Application.Volatile mystr = Right("000000" & Hex(RefCell.Interior.Color), 6) getRGB = Application.Hex2Dec(Right(mystr, 2)) & ", " & _ Application.Hex2Dec(Mid(mystr, 3, 2)) & ", " & _ Application.Hex2Dec(Left(mystr, 2)) End Function I need that this code instead of showing off rgb of other cell, would change background color of its own cell. Maybe anyone know how to do it? 回答1: The MSDN KB says

MsgBox for a range of cells

家住魔仙堡 提交于 2020-01-04 09:24:11
问题 I'm trying to create a code that displays a MsgBox if contents in cells of column G are not equal to 0. Code works with just one cell but not with the full range (G20:G100). can you please help. thanks Private Sub Worksheet_Calculate() If Sheets("Sheet1").Range("G20:G100").Value <> 0 Then MsgBox "Not equal to 0", vbOKOnly End If End Sub 回答1: Try like this: Private Sub Worksheet_Calculate() Dim myCell As Range For Each myCell In Range("G20:G100") If myCell <> 0 Then MsgBox myCell.Address & "

MsgBox for a range of cells

二次信任 提交于 2020-01-04 09:23:04
问题 I'm trying to create a code that displays a MsgBox if contents in cells of column G are not equal to 0. Code works with just one cell but not with the full range (G20:G100). can you please help. thanks Private Sub Worksheet_Calculate() If Sheets("Sheet1").Range("G20:G100").Value <> 0 Then MsgBox "Not equal to 0", vbOKOnly End If End Sub 回答1: Try like this: Private Sub Worksheet_Calculate() Dim myCell As Range For Each myCell In Range("G20:G100") If myCell <> 0 Then MsgBox myCell.Address & "

Excel VBA loop through Pivot Items

不羁的心 提交于 2020-01-04 09:19:34
问题 I want to loop through my pivot items and check if they exist in another table, see my Example Screenshot: So i want to loop through all the colors, checking if they exist in another table (e.g. in another sheet or so): Is there any way to do this so there would appear a Message Box that the color purple was not found in the list? Many thanks for your help! 回答1: You can use something like this: Sub ListMissingItems() Dim pt As PivotTable Dim pf As PivotField Dim pi As PivotItem Dim rngList As