
Selecciona celda que contiene un valor(MAx/Min) como activa
Publicado por Ariel (5 intervenciones) el 14/06/2017 18:43:28
Estimados, junto con saludar quisiera que me ayudaran con un problemita, soy nuevo en vbasic y deseo seleccionar como activa la celda que contiene un valor determinado, en este caso un minimo o un maximo, la cuestion es que la rutina me funciona en un libro nuevo, no asi en el libro que deseo, la para el maximo funciona bien, la del minimo me da cualquier cosa y se supone que es cambiar una miserable funcion, he aqui el problema:
gracias por todo ya que he aprendido mucho de esta web, saludos.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Public Sub buscastebien1()
Dim mini As Integer
f12 = Cells(Rows.Count, 7).End(xlUp).Row
mini = Application.WorksheetFunction.min(Range("G3:G" & f12))
Dim d As Variant
With ActiveSheet.Range("g3:g500")
Set d = .Find(mini, LookIn:=xlValues)
first = d.Address
Range(first).Activate
ActiveCell.Offset(0, -1).Select
MsgBox (first)
MsgBox (mini)
End With
MsgBox "The Average Power Consumption in this Campaign Was: " & ActiveCell.Value & " " & "[KW]", vbOKOnly, "Average Power"
End Sub
esa tiene el error
esta otra corre bien
Public Sub buscastebien()
Dim maxxz As Integer
fin12 = Cells(Rows.Count, 7).End(xlUp).Row
maxxz = Application.WorksheetFunction.max(Range("G3:G" & fin12))
Dim c As Variant
With ActiveSheet.Range("g3:g500")
Set c = .Find(maxxz, LookIn:=xlValues)
firstaddress = c.Address
Range(firstaddress).Activate
ActiveCell.Offset(0, -1).Select
End With
MsgBox "The Average Power Consumption in this Campaign Was: " & ActiveCell.Value & " " & "[KW]", vbOKOnly, "Average Power"
End Sub
gracias por todo ya que he aprendido mucho de esta web, saludos.
Valora esta pregunta


0