VBA: Range with variable references.

Solved
Antoine -  
 MIKE59 -
Hello everyone,
I'm having trouble finding a way to use the Range function with variables for rows and columns on the forum. Let me explain:

I have Range("A40:A500") in my code, and I want to replace A40 and A500 with variables that I've defined earlier.
Let's say my previously defined variables are ColL and LigneL, I want to replace Range(A40:A500) with something like:

Range(ColL & LigneL ":" ColL & 500) I’ve tried this in every possible way and different manners but I can’t get it to work!

Thanks in advance for your help!!

Antoine

Configuration: Windows XP / Internet Explorer 6.0

3 answers

  1. Migou76
     
    Hello,

    Try this:

    l1=1
    c2=40
    l2=1
    c2=500

    range(cells(l1,c1),cells(l2,c2)).select

    Best regards,
    Migou
    17
    1. Antoine
       
      Thank you very much, it's working!!
      0
    2. solidarinfo
       
      Hello,

      A question on the same topic:
      If
      l1= Evolves every month
      c2= Evolves every month
      l2= Evolves every month
      c2= Evolves every month

      How can we do it without forcing the user to provide an inputBox?
      0
    3. MIKE59
       

      Thanks, that's great...

      I haven't seen any Microsoft documentation stating that we can mix the range method with cells(...)...

      Excellent. I have my answer...

      Mike

      0