早上好,如何将突出显示的单元格值发送到另一列中的另一个单元格?
我做了一个宏,突出显示用户输入的单元格值,基本上它突出显示了来自列G,I和J的值。来自列G的值的值为列I或J有,但他们不是为了。我想让我的宏做的是匹配已经突出显示的这些值,并将它们移到列H,例如,如果G3具有与I5相同的值,请将值从I5移至H3。
Public Sub series()
'Definición de variables (Definition of variables)
Dim rango As String, valor As String, resultado As Range
Dim primerResultado As String, cont As Integer
'Solicitar información al usuario (Get information from the user)
rango = "A1:XFD1048576"
valor = InputBox("Ingresa el VALOR a buscar:")
If valor = "" Then Exit Sub
cont = 0 'Inicializar contador de coincidencias (Initialize Find)
'Primera búsqueda del valor dentro del rango (First search for value in the range)
Set resultado = Range(rango).Find(What:=valor, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not resultado Is Nothing Then 'Si el resultado de la búsqueda no es vacío
primerResultado = resultado.Address
Do 'Inicia bucle para hacer varias búsquedas
If MsgBox("Resaltar Valor?", vbYesNo) = vbYes Then
cont = cont + 1
resultado.Interior.ColorIndex = 4 'Cambia el color de fondo de la celda
End If
Set resultado = Range(rango).FindNext(resultado) 'Vuelve a buscar el valor
' Display a simple message box.
Loop While Not resultado Is Nothing And resultado.Address <> primerResultado
MsgBox ("Valores Encontrados: " & cont)
Else
MsgBox "Se encontraron " & cont & " coincidencias."
End If End Sub
什么是不为你工作:
值可以很容易地通过添加代码,你行后感动? – xidgel