emails a msg when value change

manuel_almeida

New Member
Joined
Feb 2, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
hi,
i have this worksheet to control the samples i must collect.
when i double clic in a day runs this code.
i want that affects only the cells in the row where i clic.(now affects all the cells in the range)
thanks in advance and sorry about my english ;)

VBA Code:
Private Sub testaColheita()
   Dim FormulaRange As Range
   Dim numero As Integer
   Dim dataregisto As Integer
   Set FormulaRange = Me.Range("AI4:AI19")
 
  On Error GoTo EndMacro:
   
For Each formulacell In FormulaRange.Cells
       With formulacell
            If IsNumeric(.Value) = False Then
                MsgBox "Valor nao numerico"
           Else
Select Case .Value
    Case Is = 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101, 106, 111, 116, 121, 126 
            'MsgBox "Colheita de Amostra (" & Cells(formulacell.Row, "A").Value & ")", vbInformation + vbOKOnly, "Alerta..."
       
           Call Mail_with_outlook2 ' envia email
            Application.EnableEvents = False
    Cells(formulacell.Row, "C").Value = Now() 'escreve a data
    formulacell.Offset(0, 1).Value = 0 ' zera o contador
            Application.EnableEvents = True
          
    Case Is = 2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 24, 25, 27, 28, 29, 30, 32, 33, 34, 35, 37, 38, 39, 40, 42, 43, 44, 45, 47, 48, 49, 50, 52, 53, 54, 55, 57, 58, 59, 60
            
             Application.EnableEvents = False
            formulacell.Offset(0, 1).Value = formulacell.Offset(0, 1).Value + 1 'regista +1 no contador
            dataregisto = DateDiff("m", Cells(formulacell.Row, "C").Value, Now())
            MsgBox dataregisto
    Application.EnableEvents = True
    Case Else
        Exit Sub
    End Select
End If
End With
    Next formulacell
ExitMacro:
    Exit Sub
EndMacro:
    Application.EnableEvents = True

    MsgBox "Some Error occurred." _
         & vbLf & Err.number _
         & vbLf & Err.Description
End Sub
 

Attachments

  • sample.png
    sample.png
    41.4 KB · Views: 5

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,885
Messages
6,122,090
Members
449,065
Latest member
Danger_SF

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top