+ Reply to Thread
Results 1 to 8 of 8

Thread: Getting activesheet.range to refer to a name that varies...

  1. #1
    Registered User
    Join Date
    04-24-2009
    Location
    Manitoba, Canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    Getting activesheet.range to refer to a name that varies...

    Hi, I'm extremely new to VBA and would love some advice. I'll try to explain as best I can. (Sorry for any improper wording...)

    I have a little form on an Excel worksheet. It includes a field for an Organization Name, and a combo box drop-down to select a Date. On another worksheet, I have a calendar. Each date box on the calendar (ranges of three cells) has been named "May 1", etc., exactly like the options on the Date drop-down list.

    I want the user to fill out the form, click a button and have the data from Organization Name to appear in the appropriate calendar box, depending on what Date the user has entered on the form.

    Essentially, I want to modify this:
        Sheets("Calendar View").Activate
        ActiveSheet.Range("name").Select
    so that "name" refers to the value of "drop_date" (which is the name of the combo box that contains the date).

    Hope I explained that correctly. Any help would be greatly appreciated!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Getting activesheet.range to refer to a name that varies...

    Hello karen000,

    Welcome to the Forum!

    Formatting obviously plays a big part in your description. Help us to help you and post your workbook. This will save time and assure that a custom solution will match what you want.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-24-2009
    Location
    Manitoba, Canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Getting activesheet.range to refer to a name that varies...

    Example file is attached.

    Example.xls

    This is a very dirty semi-recreation of the file I'm talking about. I named the May 1 calendar box "name" so you can see what I mean. Unfortunately (obviously) even if you enter "May 3", it will enter the information on the calendar on May 1.

    I need Excel to know which range to select from what the user chooses under "date".

    Thanks again!

  4. #4
    Registered User
    Join Date
    04-24-2009
    Location
    Manitoba, Canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Getting activesheet.range to refer to a name that varies...

    .....bump.....?

  5. #5
    Registered User
    Join Date
    04-24-2009
    Location
    Manitoba, Canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Getting activesheet.range to refer to a name that varies...

    30 views and no replies... I guess I really have no idea what I'm talking about?

  6. #6
    Forum Guru VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    12,010

    Re: Getting activesheet.range to refer to a name that varies...

    This will select the range

    Application.Goto Reference:=drop_date.Value
    This will Set the Range

    Dim Rng As Range
      Set Rng = Sheets("Calendar View").Range(drop_date.Value)
    If you want
    txt_organization.Value
    in the first cell of the range then use

    Rng(1) = txt_organization.Value
    Repeat for 2nd Cell in Range 2 etc

    HTH

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  7. #7
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: Getting activesheet.range to refer to a name that varies...

    you need patience - this is a worldwide forum so members are online at different times. Also, the help is offered for free & depends on members having spare time.

    Your idea will prove cumbersome, needing to create all those named ranges. I have amended your calendar so that the days are generated by formulas and formatted as dd to display the number.

    The comboboxes load correctly when the sheet is activated.

    Enter the date by clicking into C7 to display a calendar to pick the date

    The data is input into the day on the calendar sheet
    Attached Files Attached Files
    Last edited by royUK; 04-25-2009 at 06:01 AM. Reason: improved workbook
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  8. #8
    Registered User
    Join Date
    04-24-2009
    Location
    Manitoba, Canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Getting activesheet.range to refer to a name that varies...

    Thank you both so much for all your help... I HATE working with VBA, and realized that I had messed up the whole example document after I posted it (did it hastily).

    Unfortunately I am obviously in way over my head and have no idea even where to put the mentioned codes, but thank you very much anyway.
    Last edited by karen000; 05-01-2009 at 05:14 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0