1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to select a range in a single Row by using two variables in VBA

Discussion in 'VBA Macros' started by Ali Asgar, Feb 11, 2019.

  1. Ali Asgar

    Ali Asgar New Member

    Messages:
    2
    Hi Friends,
    I want to select a range in a single Row by using two variables. For Example if I want to select B9 to B88, I need to store 9 & 88 in variables. Any pointers would be a great help.

    Thanks,
    Ali
  2. Hui

    Hui Excel Ninja Staff Member

    Messages:
    11,726
    Ali

    Firstly, Welcome to the Chandoo.org Forums

    Here are 3 ways

    Code (vb):
    Sub Select_Cells()
    Dim StartRow As Integer, EndRow As Integer
    StartRow = 9
    EndRow = 88

    Range("B" & StartRow & ":B" & EndRow).Select
    Range(Cells(StartRow, 3), Cells(EndRow, 3)).Select
    Range("D" & StartRow).Resize(EndRow - StartRow, 1).Select

    End Sub
  3. Ali Asgar

    Ali Asgar New Member

    Messages:
    2
    Thanks Hui for the help and support!

Share This Page