Hi!
Thanks for your help so far, got it to check and push things down. A bit more detailed:
What I meant with populate is that I have about 21 columns of data that get extracted from another workbook (Hence didn't write it earlier... forgot to mention it, sorry
). So once the relevant project is found, all the previous data is pushed down and each cell of the row gets the new information (in the sample it would be,first the project, then the version (+1) and then the city.All of the data may or may not be the same). All of this data is stored in vba variables and copied from the original projects workbook.
The tool is part of a controlling mechanism to check the development of costs and such things. Thus first search for projects and add one to the version of the workbook
If the project isn't found then it gets inserted at the top so that it can be used as a visual cue for a follow up.
The updated code that I have gets stuck at "c.Offset(0,2).Value = St_Location" (runtime error 438):
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)
c.Select
c.Value = St_Project
c.Offset(0, 1).FormulaR1C1 = "=R[1]C+1"
c.Offest(0, 2).Value = St_Location
End If
End With
Again, many thanks in advance!!! Do let me know if you find that I left something out
Bookmarks