1

I have a little problem in VBA, I want to put row and column of Range function in String format like that :

    debut = "BH" & LTrim(Str(i))
    fin = "DB" & LTrim(Str(i))
    For Each Cell In Ws.Range("debut:fin")

But i have an error, how can i resolve it ? Thanks

1 Answer 1

3

The way you have done it ("debut:fin"), the range is really equal to that string and is invalid. What you need to do is concatenate the 2 strings with a : in between with the & operator:

For Each Cell In Ws.Range(debut & ":" & fin)
Sign up to request clarification or add additional context in comments.

1 Comment

+ 1 :) Also "BH" & LTrim(Str(i)) can also be written as "BH" & i

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.