dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,373
- Office Version
- 365
- 2016
- Platform
- Windows
I have 3 signature buttons that call a procedure each to insert the relevant signature. The 3 called subs are almost identical with the only difference being the signature image to use. I want to just have one sub and send data from the caller subs to specify which signature needs to be inserted. I know it is using arguments but I not sure how to do this. Could someone help me please?
3 caller subs
3 called subs
3 caller subs
VBA Code:
Private Sub cmdGB_Click()
Quoting.Unprotect password:=ToUnlock
Call cmdNoSig
cmdGarrettSig
'Quoting.Protect password:=ToUnlock
End Sub
Private Sub cmdLS_Click()
Quoting.Unprotect password:=ToUnlock
Call cmdNoSig
Call cmdLynSig
'Quoting.Protect password:=ToUnlock
End Sub
Private Sub cmdTS_Click()
Quoting.Unprotect password:=ToUnlock
Call cmdNoSig
Call cmdTraceySig
'Quoting.Protect password:=ToUnlock
End Sub
3 called subs
VBA Code:
Function LastRow()
'Dim LastRow As Long
With Sheets("CSS_quote_sheet")
LastRow = .Range("A:H").Find(What:="*", _
After:=.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
End With
End Function
Sub cmdGSig()
Dim a As Double, aa As Double, aaa As Double
Application.ScreenUpdating = False
With Sheets("Sheet2")
.Shapes("ImgG").Duplicate.Name = "Signature"
.Shapes("Signature").Cut
End With
Sheets("CSS_quote_sheet").Cells(43, 1).PasteSpecial
Sheets("CSS_quote_sheet").Shapes(Selection.Name).Name = "Signature"
a = Sheets("CSS_quote_sheet").Cells(LastRow, 1).Top + 140
aa = Sheets("CSS_quote_sheet").Shapes("Signature").Height
aaa = Rows(Sheets("CSS_quote_sheet").HPageBreaks(1).Location.Row).Top + 1
With Sheets("CSS_quote_sheet").Shapes("Signature")
.Left = ActiveSheet.Range("A1").Left
.Top = IIf(a + aa > aaa, aaa, a)
.Placement = 1
End With
Application.ScreenUpdating = True
End Sub
Sub cmdTSig()
Dim a As Double, aa As Double, aaa As Double
Application.ScreenUpdating = False
With Sheets("Sheet2")
.Shapes("ImgT").Duplicate.Name = "Signature"
.Shapes("Signature").Cut
End With
Sheets("CSS_quote_sheet").Cells(43, 1).PasteSpecial
Sheets("CSS_quote_sheet").Shapes(Selection.Name).Name = "Signature"
a = Sheets("CSS_quote_sheet").Cells(LastRow, 1).Top + 140
aa = Sheets("CSS_quote_sheet").Shapes("Signature").Height
aaa = Rows(Sheets("CSS_quote_sheet").HPageBreaks(1).Location.Row).Top + 1
With Sheets("CSS_quote_sheet").Shapes("Signature")
.Left = ActiveSheet.Range("A1").Left
.Top = IIf(a + aa > aaa, aaa, a)
.Placement = 1
End With
Application.ScreenUpdating = True
End Sub
Sub cmdLSig()
Dim a As Double, aa As Double, aaa As Double
Application.ScreenUpdating = False
With Sheets("Sheet2")
.Shapes("ImgL").Duplicate.Name = "Signature"
.Shapes("Signature").Cut
End With
Sheets("CSS_quote_sheet").Cells(43, 1).PasteSpecial
Sheets("CSS_quote_sheet").Shapes(Selection.Name).Name = "Signature"
a = Sheets("CSS_quote_sheet").Cells(LastRow, 1).Top + 140
aa = Sheets("CSS_quote_sheet").Shapes("Signature").Height
aaa = Rows(Sheets("CSS_quote_sheet").HPageBreaks(1).Location.Row).Top + 1
With Sheets("CSS_quote_sheet").Shapes("Signature")
.Left = ActiveSheet.Range("A1").Left
.Top = IIf(a + aa > aaa, aaa, a)
.Placement = 1
End With
Application.ScreenUpdating = True
End Sub