Ok guys and gals, I've managed to put together the below code and have come to a point where further assiatance is required.
It uses a userform to find a saved document and paste the info into a database for specific cases. I have my set templates and they have defined columns but correspondence that are manually created (or received) need to be saved into a cell in the case row but there could only be 2 letters on one case and maybe 100 letters on another.
I am trying to find a way to carry out the below on an expenential basis. Search for the first cell, if it is blank move on 3 and keep going until you find an empty cell then paste the values in the two defined cells.
Can anyone work out how this can be done because I have spent a good couple of days thinking it through and have come up with nadda.
Private Sub CommandButton2_Click()
Dim UserId as String
Dim CaseId as String
Dim SearchString As String
UserId = Letters.User.Value
CaseId = Letters.CaseNo.Value
SearchString = UserId & CaseId
i = 85
' Search Case Reference Number column from database based on two values in Userform
'
'
Letters.Browse.Copy
If Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i).Value = "" Then
On Error Resume Next
Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i).Value = Letters.Browse.Value
Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i + 1).Value = Letters.Description.Value
On Error GoTo 0
Else
On Error Resume Next
Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i + 3).Value = Letters.Browse.Value
Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i + 4).Value = Letters.Description.Value
On Error GoTo 0
End If
Letters.Hide
End Sub
Bookmarks