Ozgrid Excel Help & Best Practices Forums

Excel Training / Excel Dashboards Reports

Results 1 to 2 of 2

Thread: VBA - Refer to a Column in Cell

  1. #1
    Join Date
    15th June 2017

    VBA - Refer to a Column in Cell


    But I want to make it dynamic where DD and DI are listed in cells say A1 and A2. How do I convert the syntax to reference the cells?

    Thank you in advance! I am super bad at syntax... I tired Columns(Range("A1") & ":" & Range("A2")).Select

    Excel Video Tutorials / Excel Dashboards Reports

  2. #2
    Join Date
    13th March 2014
    Indiana, USA

    Re: VBA - Refer to a Column in Cell

    Hi toofxd, and welcome to the forum!
    You were close. Need to specify that you wanted the values from those ranges. Could do this in one step, but spacing it out for visibility
    Sub ExampleCode() 
        Dim firstCol As String 
        Dim secCol As String 
         'What cells are our controls in?
        firstCol = Range("A1").Value 
        secCol = Range("A2").Value 
         'Use that info to build our range string
        Range(firstCol & ":" & secCol).FillRight 
    End Sub 
    Best Regards,
    Luke M
    "A little knowledge is a dangerous thing."

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Making a cell refer to a cell address even if content moved
    By Porsche Tony in forum Excel General
    Replies: 1
    Last Post: March 2nd, 2017, 21:50
  2. Replies: 1
    Last Post: January 26th, 2012, 11:19
  3. refer to more than one column w/offset
    By JMAN in forum Excel General
    Replies: 11
    Last Post: March 3rd, 2006, 02:46
  4. Refer to Specific Column in a Number
    By danilane in forum Excel General
    Replies: 5
    Last Post: October 22nd, 2005, 08:39
  5. Replies: 3
    Last Post: September 28th, 2005, 06:47


Posting Permissions

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