Hi!
Was a few days unexpectedly away... I have now managed to tackle the problem by going line by line... Problem was that "c" was being assigned a string if the variable was found... Solution:
Dim EW_ECK As Workbook
Dim summary As Worksheet
Dim c As Range
Dim St_Project As String
Dim St_Location As String
Set EW_ECK = Workbooks.Open("S:\Eckdatenblatt\Sample_Eckdatenblatt.xlsx")
Set Summary = EW_ECK.Sheets("Summary")
Summary.Activate
St_Project = "Other project"
St_Location = "London"
With Summary.Columns(1)
'Find match.
Set c = .Find(What:=St_Project, After:=Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
'If no match, prepare to insert on top.
If c Is Nothing Then
Set c = .Cells(2, 1)
'Do the insert.
c.EntireRow.Insert (xlDown)
c = St_Project
c.Offset(0, 1).Value = 1
c.Offset(0, 2).Value = St_Location
Else
c.EntireRow.Insert (xlDown)
Set c = c.Offset(-1, 0)
c.Activate
c.Value = St_Project
c.Offset(0, 1).FormulaR1C1 = "=R[1]C+1"
c.Offest(0, 2).Value = St_Location
End If
End With
Many thanks for helping me out with figuring out how to do the search!!
Bookmarks