0

I have following formula

=IF(Matching_Sheet!F3=0;"";Matching_Sheet!F3)

I want to let VBA fill in the B column of a sheet with this formula adjusted to the respective column number. I have tried this

For x = 2 To destMaxRow
Range("$B$" & x).FormulaLocal = "=IF(Matching_Sheet!$F$=0;" & x & Chr(34) & Chr(34) & ";Matching_Sheet!$F$)" & x
Next

Unfortunately, this form apparently has a mistake but I cannot figure out what it is.

Any help would be appreciated. Thanks in advance.

0

1 Answer 1

1

Not sure, try this

For x = 2 To destMaxRow
  Range("$B$" & x).FormulaLocal = "=IF(Matching_Sheet!$F$" & x & "=0;" & Chr(34) & Chr(34) & ";Matching_Sheet!$F$" & x & ")"
Next

Which I think could be shortened to (obviating need for a loop)

Range("$B$2:B" & destMaxRow).FormulaLocal = "=IF(Matching_Sheet!$F2=0;" & Chr(34) & Chr(34) & ";Matching_Sheet!$F2)"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.