-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcat_sub().vba
51 lines (35 loc) · 1.12 KB
/
concat_sub().vba
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Dim ultimaAlteracaoJ6 As Boolean
Sub concat_sub()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim x As Variant
Sheets("Soufer").Activate
If Range("E5").value = "" Then
MsgBox "ERRO - Nota Fiscal Vazia"
Exit Sub ' Ends the macro if cell E5 is empty
End If
' Disables screen updating and events to improve performance
Application.ScreenUpdating = False
Application.EnableEvents = False
' Activates the "Soufer" sheet
Sheets("Soufer").Activate
' Concatenates the values of cells E5 and J6
x = Range("E5").value & Range("J6").value
' Activates the "Consulta" sheet
Sheets("Consulta").Activate
' Sets the value in cell B1 to the concatenated value
Range("B1").value = x
' Clears the clipboard
Application.CutCopyMode = False
Application.Wait Now + TimeSerial(0, 0, 0.5)
' Returns to the "Soufer" sheet
Sheets("Soufer").Activate
Range("J6").Select
' Re-enables screen updating and events
Application.ScreenUpdating = True
Application.EnableEvents = True
' Indicates that the last change was in J6
ultimaAlteracaoJ6 = True
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub