Hey there,
I am new on here, please bear with me. I have already knocked my head against the wall for a few hours and done lots of researching of examples, but I can't get there unfortunately.
So what I was planning is pretty straight forward:
The values are processed fine, i.e. the value to be replaced "LastDay" and replacement value "NewDay" are ok. It is just the replacement that does not work.
Any help would be great.
Thank you,
Lars
Sub NewDay()
'
' NewDay Macro
'
Dim LastDay As Long
Dim NewDay As Long
LastDay = Worksheets("Info").Cells(5, "S").Value
NewDay = LastDay + 1
'Just to check that Values are ok, can be deleted later
Range("A43").Value = LastDay
Range("A44").Value = NewDay
ActiveCell.Offset(-2, 0).Rows("1:2").EntireRow.Select
Selection.Copy
ActiveCell.Offset(2, 0).Rows("1:2").EntireRow.Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Selection.Replace What:="LastDay", Replacement:="NewDay", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
I am new on here, please bear with me. I have already knocked my head against the wall for a few hours and done lots of researching of examples, but I can't get there unfortunately.
So what I was planning is pretty straight forward:
- Copy 2 rows from above selected cell and insert
- Replace a value in the equation (it is a number in a text directory, i.e. date) for the newly inserted 2 rows
- Value of replacement to change based on dates. E.g. 20th of August = 20170820, 21st of August= 20170821.
- The equation in which the number replacement is to take place is as follows:
- So it is a number that I need to add 1 to every day, but it is a text replacement?
The values are processed fine, i.e. the value to be replaced "LastDay" and replacement value "NewDay" are ok. It is just the replacement that does not work.
Any help would be great.
Thank you,
Lars
Sub NewDay()
'
' NewDay Macro
'
Dim LastDay As Long
Dim NewDay As Long
LastDay = Worksheets("Info").Cells(5, "S").Value
NewDay = LastDay + 1
'Just to check that Values are ok, can be deleted later
Range("A43").Value = LastDay
Range("A44").Value = NewDay
ActiveCell.Offset(-2, 0).Rows("1:2").EntireRow.Select
Selection.Copy
ActiveCell.Offset(2, 0).Rows("1:2").EntireRow.Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Selection.Replace What:="LastDay", Replacement:="NewDay", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub