dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,392
- Office Version
- 365
- 2016
- Platform
- Windows
I have a procedure that pushes a signature to the next page if it is over the page break.
The procedure worked fine when there was only 1 signature but now there are several. I have just realised that I have not been using this code (which I should have been) and I added four separate buttons and used the following code for each.
I could copy the cmdPush and modify it slightly for each different signature but I wanted to have a procedure behind each of the signature buttons that would send the image name to cmdPush as an argument and it could substitute it in where ImgG already is. Only problem is that I am not sure of the code. Could someone help me please?
VBA Code:
Sub cmdPush()
Dim a As Double, aa As Double, aaa As Double, DividerBottom As Long
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).End(xlUp).Offset(1).Top + 140
aa = Sheets("CSS_quote_sheet").Shapes("Signature").Height
aaa = Rows(Sheets("CSS_quote_sheet").HPageBreaks(1).Location.Row).Top + 1
DividerBottom = Sheets("CSS_quote_sheet").Shapes("Divider").BottomRightCell.Row
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
The procedure worked fine when there was only 1 signature but now there are several. I have just realised that I have not been using this code (which I should have been) and I added four separate buttons and used the following code for each.
VBA Code:
Sub cmdTraceySig()
Sheets("Sheet2").Shapes("ImgT").Copy
ActiveSheet.Paste Destination:=ActiveSheet.Cells(1, 1)
Selection.Top = Cells(LastRow, 1).Top + "100"
End Sub
Sub cmdLynSig()
Sheets("Sheet2").Shapes("ImgL").Copy
ActiveSheet.Paste Destination:=ActiveSheet.Cells(1, 1)
Selection.Top = Cells(LastRow, 1).Top + "100"
End Sub
Sub cmdGarrettSig()
Sheets("Sheet2").Shapes("ImgG").Copy
ActiveSheet.Paste Destination:=ActiveSheet.Cells(1, 1)
Selection.Top = Cells(LastRow, 1).Top + "100"
End Sub
Sub cmdJonathanSig()
Sheets("Sheet2").Shapes("ImgJ").Copy
ActiveSheet.Paste Destination:=ActiveSheet.Cells(1, 1)
Selection.Top = Cells(LastRow, 1).Top + "100"
End Sub
I could copy the cmdPush and modify it slightly for each different signature but I wanted to have a procedure behind each of the signature buttons that would send the image name to cmdPush as an argument and it could substitute it in where ImgG already is. Only problem is that I am not sure of the code. Could someone help me please?