Cell to be activated, which is a result of a vlookup formula
On Tuesday, 4 February 2020 07:54:47 UTC+2, Norbert wrote:
Hi Claus,
thanks for your reply!
I am trying to incorporate your code into my macro but it stops at line:
Application.Goto .Range("F" & c.Row)
with following message: Run-time error 91: Object variable or With block variable not set!
Herewith my macro and how I tried to make use of your code:
Sub FEED_STOCK_REQUIREMENTS()
Range("I6:L6").Select
Selection.ClearContents
Range("F6").Select
Selection.Copy
Range("I6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("I6"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="+", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("L6").Select
ActiveCell.FormulaR1C1 = "=RC[-5]/COUNTA(RC[-3]:RC[-1])"
Range("B6").Select
' Goto the cell which was found by the vlookup formula in
' Sheet("Input").Range(I8)
Dim c As Range
Dim myStr As String
With Sheets("Input")
myStr = .Range("H6") & "-" & .Range("I6")
End With
With Sheets("Stock sheet")
Set c = .Range("A:A").Find(myStr)
Application.Goto .Range("F" & c.Row)
End With
End Sub
Hi Claus,
it works, the problem was that I actually had formulas in Range (A:A) on sheet "Stock sheet" and not values. The formulas created the string I was searching with the vlookup formula.
This is one of the formulas: =C5&"-"&D5
It would be great if it was working with the formulas, otherwise I have to come up with another idea.
|