+ Reply to Thread
Results 1 to 3 of 3

Reference Worksheet Named from User Input

Hybrid View

TxNyCa Reference Worksheet Named... 05-21-2014, 07:08 PM
GC Excel Re: Reference Worksheet Named... 05-21-2014, 08:42 PM
TxNyCa Re: Reference Worksheet Named... 05-22-2014, 12:34 PM
  1. #1
    Registered User
    Join Date
    02-27-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    9

    Reference Worksheet Named from User Input

    My code is breaking in two spots where I am trying to reference a cell range on a worksheet named by user input--"myValue" is the variable.

    FIRST BREAK:
    ActiveCell.FormulaR1C1 = _
    "=UPPER(TEXT(INDEX(Sheets(myValue)!C[-2],COUNTA(Sheets(myValue)!C[-2]),1),""mmmm d, yyyy""))"

    SECOND BREAK:
    ActiveChart.SeriesCollection(1).XValues = _
    "=Sheets(myValue)!B2:B500"

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Reference Worksheet Named from User Input

    Maybe like this :

    ActiveCell.FormulaR1C1 = _
    "=UPPER(TEXT(INDEX(Sheets(" & myValue & ")!C[-2],COUNTA(Sheets(" & myValue & ")!C[-2]),1),""mmmm d, yyyy""))"
    and

    ActiveChart.SeriesCollection(1).XValues = "=Sheets(" & myValue & ")!B2:B500"
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Registered User
    Join Date
    02-27-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Reference Worksheet Named from User Input

    Unfortunately it did not work. Any other thoughts? My full code is below:

    Sub GenerateGraph()
    '
    ' GenerateGraph Macro
    '
    
     Dim myValue As Variant
     myValue = InputBox("Enter the Name of Client Return Stream", "Graph Name", "Client Graph")
      Range("I1").Value = myValue
    
    ActiveSheet.Select
    ActiveSheet.Name = myValue
    Sheets.Add
             Cells.Select
        With Selection.Font
            .Name = "Calibri"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        With Selection.Font
            .ThemeColor = xlThemeColorAccent1
            .TintAndShade = -0.249977111117893
        End With
        
        Range("A1").Value = myValue
        Range("A2").Select
        ActiveCell.FormulaR1C1 = "CUMULATIVE GROWTH OF CAPITAL SINCE INCEPTION"
        Range("A3").Select
        ActiveCell.FormulaR1C1 = "NET OF FEES AS OF:"
         Range("D3").Select
         ActiveCell.FormulaR1C1 = _
            "=UPPER(TEXT(INDEX(Sheets(" & myValue & ")!C[-2],COUNTA(Sheets(" & myValue & ")!C[-2]),1),""mmmm d, yyyy""))"
      
        
            Range("A5").Select
        ActiveSheet.Shapes.AddChart.Select
        ActiveChart.ChartType = xlLine
    
        ActiveChart.PlotArea.Select
        ActiveChart.SetSourceData Source:=Sheets(myValue). _
            Columns("I:N")
    
        ActiveChart.SeriesCollection(1).XValues = _
            "=sheets(" & myValue & ")!B2:B500"
    
        ActiveChart.ChartArea.Select
        ActiveSheet.Shapes("Chart 1").IncrementLeft -518.25
        ActiveSheet.Shapes("Chart 1").IncrementTop -131.25
        ActiveSheet.Shapes("Chart 1").ScaleWidth 1.5270833333, msoFalse, _
            msoScaleFromTopLeft
        ActiveSheet.Shapes("Chart 1").ScaleHeight 2.0347222222, msoFalse, _
            msoScaleFromTopLeft
        ActiveChart.PlotArea.Select
        Selection.Width = 428.388
        ActiveChart.ChartArea.Select
        ActiveSheet.Shapes("Chart 1").ScaleWidth 1.1664394338, msoFalse, _
            msoScaleFromTopLeft
        ActiveSheet.Shapes("Chart 1").ScaleHeight 1.1160409556, msoFalse, _
            msoScaleFromTopLeft
        ActiveSheet.Shapes("Chart 1").IncrementLeft -15.7499212598
        ActiveSheet.Shapes("Chart 1").IncrementTop -18.75
            ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveSheet.Shapes("Chart 1").Height = 412.56
        ActiveSheet.Shapes("Chart 1").Width = 708.48
          Dim mySrs As Series
          Dim nPts As Long
          For Each mySrs In ActiveChart.SeriesCollection
          With mySrs
            nPts = .Points.Count
            mySrs.Points(nPts).ApplyDataLabels _
                Type:=xlDataLabelsShowValue, _
                AutoText:=True, LegendKey:=False
            mySrs.Points(nPts).DataLabel.Text = mySrs.Name
          End With
          Next
    
    
    End Sub
    Last edited by TxNyCa; 05-22-2014 at 12:53 PM. Reason: Included workbook

+ 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. How to reference a table named in an input box?
    By JoeSkittles in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2013, 03:06 PM
  2. search named ranges with user input
    By KrZyMiC in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-16-2011, 07:15 PM
  3. User Input Form to worksheet
    By meister14 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2010, 10:31 PM
  4. User Input to change cell reference in formulas
    By williampdx in forum Excel General
    Replies: 5
    Last Post: 03-31-2010, 02:04 PM
  5. How to reference a cell based on user input?
    By ChromiumBlue in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 12-14-2006, 11:39 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