Consulting

Results 1 to 3 of 3

Thread: VBA Excel - reduction of lines

  1. #1
    VBAX Newbie
    Joined
    Oct 2022
    Posts
    2
    Location

    VBA Excel - reduction of lines

    I have this string in my code, but the "List"numbers keep increasing, so I would like to have one line including all lists.

    If Range("R2") = "Liste1" Then Set Kapacitet = Range("Liste1")
    If Range("R2") = "Liste2" Then Set Kapacitet = Range("Liste2")
    If Range("R2") = "Liste3" Then Set Kapacitet = Range("Liste3")
    If Range("R2") = "Liste4" Then Set Kapacitet = Range("Liste4")
    If Range("R2") = "Liste5" Then Set Kapacitet = Range("Liste5")
    If Range("R2") = "Liste6" Then Set Kapacitet = Range("Liste6")
    If Range("R2") = "Liste7" Then Set Kapacitet = Range("Liste7")
    If Range("R2") = "Liste8" Then Set Kapacitet = Range("Liste8")

    The syntax is the same for all lists.

    Thanks for suggestions.

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,638
    Sub M_snb()
      Set Kapacitet = Range(Range("R2").Value)
    end sub

  3. #3
    VBAX Newbie
    Joined
    Oct 2022
    Posts
    2
    Location
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •