Sub post()
Fillpost
End Sub
Public Function Fillpost()
Dim row(1 To 10) As String
Dim con(1 To 4) As String
Dim s1, s2 As String
Dim r(1 To 10) As String
Const Section1 As String = "Fruits"
Const Section2 As String = "Cars"
Const Section3 As String = "Comments"
s1 = InputBox(Prompt:="Please enter Master Template Name", _
Title:="Master Report Name", Default:="master")
s2 = InputBox(Prompt:="Please enter Report Template Name", _
Title:="Report Name", Default:="report")
row1 = 0
row2 = 0
row3 = 0
row4 = 0
row5 = 0
row6 = 0
On Error GoTo NotFound
row1 = Sheets(s1).UsedRange.Find(What:=Section1, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).row
row2 = Sheets(s1).UsedRange.Find(What:=Section2, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).row
row3 = Sheets(s1).UsedRange.Find(What:=Section3, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).row
row4 = Sheets(s2).UsedRange.Find(What:=Section1, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).row
row5 = Sheets(s2).UsedRange.Find(What:=Section2, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).row
row6 = Sheets(s2).UsedRange.Find(What:=Section3, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).row
row7 = row2 - 1
row8 = row3 - 1
row9 = row5 - 1
row10 = row6 - 1
con1 = row1 & ":" & row7
con2 = row2 & ":" & row8
con3 = row4 & ":" & row9
con4 = row5 & ":" & row10
MsgBox "Fruits in master: " & con1 & vbCrLf & _
"Cars in master: " & con2
MsgBox "Fruits in report " & con3 & vbCrLf & _
"Cars in report " & con4
r1 = "Kiwi"
If Trim(r1) <> "" Then
With Sheets(s1).Range(con1)
Set c = .Find(What:=r1, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False)
If Not c Is Nothing Then
MsgBox "Kiwi Found"
Else
MsgBox "Kiwi Not found"
End If
End With
End If
r2 = "Country A"
If Trim(r2) <> "" Then
With Sheets(s1).Range("6:40")
Set c2 = .Find(What:=r2, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False)
If Not c2 Is Nothing Then
MsgBox "Country A Found"
Else
MsgBox "Country A Not found"
End If
End With
End If
r3 = "Company A"
If Trim(r3) <> "" Then
With Sheets(s1).Range("6:40")
Set c2 = .Find(What:=r3, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False)
If Not c2 Is Nothing Then
MsgBox "Company A Found"
Else
MsgBox "Company A not found"
End If
End With
End If
r4 = "With Seed"
If Trim(r4) <> "" Then
With Sheets(s1).Range("6:40")
Set c2 = .Find(What:=r4, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False)
If Not c2 Is Nothing Then
MsgBox "With Seed Found"
Else
MsgBox "With Seed Not found"
End If
End With
End If
Exit Function
NotFound: MsgBox "Item not found"
End Function
Bookmarks