+ Reply to Thread
Results 1 to 5 of 5

change cell reference based on vba code

  1. #1
    Forum Contributor
    Join Date
    09-09-2014
    Location
    England
    MS-Off Ver
    2013
    Posts
    102

    change cell reference based on vba code

    I am trying to get my textboxes to change based on a dropdown list. I have:

    If Me.LookUpItem.Value = Range("ao2") Then Me.Stem1 = Range("a2")
    If Me.LookUpItem.Value = Range("ao3") Then Me.Stem1 = Range("a3")

    End Sub

    What I would like is to change where the code looks up it's value i.e. if ao7 is selected then range would become a7 etc. without having to write masses of code.

    Any ideas, it's probably quite simple.

    Z

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: change cell reference based on vba code

    Unclear exactly what you want, but...
    Please Login or Register  to view this content.
    Perhaps...?

  3. #3
    Forum Contributor
    Join Date
    09-09-2014
    Location
    England
    MS-Off Ver
    2013
    Posts
    102

    Re: change cell reference based on vba code

    That doesn't do what I want. I'm trying to get each range to change based on a combobox selection. So for example if the combobox picks a selection from range a7 my textbox1 will select b7, if my combobox selects from a100 then textbox1 will select from b100.

    Does that makes sense?

    Z

  4. #4
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: change cell reference based on vba code

    Hi,

    Please share your workbook to check what have you done and what your code looks like?

    Regards,
    Paresh J
    Click on "* Add Reputation" as a way to say thanks

  5. #5
    Forum Contributor
    Join Date
    09-09-2014
    Location
    England
    MS-Off Ver
    2013
    Posts
    102

    Re: change cell reference based on vba code

    I can't share my workbook but my code looks like this:

    If Me.LookUpItem.Value = Range("ao2") Then Me.Stem1 = Range("a2")
    If Me.LookUpItem.Value = Range("ao3") Then Me.Stem1 = Range("a3")

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to change the reference worksheet based on a value of a cell
    By macnabong in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2014, 09:33 AM
  2. Replies: 5
    Last Post: 04-28-2014, 07:54 AM
  3. [SOLVED] Change Year in Macro with reference to cell in Working code.
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2013, 02:11 PM
  4. Formula/Script to change reference cell based on date?
    By rbtroj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2012, 11:56 AM
  5. [SOLVED] I want to change a cell reference based on where the cursor is.
    By 7redmetal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2005, 03:45 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1