So I have this code which finds a specific string on a sheet called Master Trainings
and finds the address of the cell to the right of it. That is all fine. Right before this, I have a piece of code which creates a line and puts that same text in a cell, say D4. w
here is the r1c1 address of the row above (i.e. 3
in this case). I have NewCourseCell
which returns the address of the cell I want perfectly, but I am not sure why the last line fails to create the formula I want inside that cell.
Dim findRng25 As Range
Dim foundRng25 As Range
Set findRng25 = Sheets("Master Trainings").Range("A:A")
Set foundRng25 = findRng25.Find(Cells(w + 1, 4).Value)
Dim C25 As Variant
C25 = Cells(foundRng25.Row, foundRng25.Column + 1).Address(0, 0)
NewCourseCell = Cells(w + 1, 5).Address
Range(NewCourseCell).Formula = "=B9*'Master Trainings'!" & C25 & ",0)"
As mentioned in the comments by @PEH, this part of the formula is a bit useless – ",0)"
. There is only one )
and the ,0
is not required.
This is some minimal code, that works, if you have Master Trainings
worksheet:
Public Sub TestMe()
Dim c25 As String
c25 = "D10"
Range("B2").Formula = "=B9*'Master Trainings'!" & c25
End Sub
Tags: excelexcel, input, vba