Hi all,
Have been working with VBA a bit now, still a noob but learning everyday thanks to these forums.
I simply have 2 codes that i want to assign to the same button, the first code is a kind of vlookup type copy and paste, and the second a output to pdf.
I have tried joining together but keep getting errors. Any help be great. Please see codes below as two separate subs
Sub matchEm()
Dim vRow, vColumn
Dim sht1 As Excel.Worksheet
Dim sht2 As Excel.Worksheet
Set sht1 = Sheets("Sheet1")
Set sht2 = Sheets("Sheet2")
vRow = Application.Match(sht1.Range("B1").Value, sht2.Range("B:B"), 0)
If Not IsError(vRow) Then
vColumn = Application.Match(sht1.Range("B4").Value2, sht2.Range("2:2"), 0)
If Not IsError(vColumn) Then sht2.Cells(vRow, vColumn).Resize(4).Value = Application.Transpose(sht1.Range("D8:G8").Value)
End If
End Sub
Sub PDF()
sht1.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="O:\Operations\QHSE\Briefings\" & Cells(2, 1).Value & " - " & Cells(3, 2).Value & ".pdf", _
OpenAfterPublish:=True
End Sub
What I need is to join these two subs together into one, I thought a "Then" function would have done this but to no avial
Thanks in Advance
Bookmarks