0

So here is the code that I am working with:

c = Application.Match("Test", Range("F1:F130"), 0)        
    ActiveChart.SeriesCollection(1).XValues = "='" & shtname & "'" &  "!$B$104:$N$104"

So similar to the plot I would want to be able to say because c+4 = some integer which is not always 104.

ActiveChart.SeriesCollection(1).XValues = "='" & shtname & "'" &  "!$B$(c+3):$N$(c+3)"

I have tried using doing something like:

ActiveChart.SeriesCollection(1).XValues = "='" & shtname & "'" & "!$B$" & " (c+3):$N$" & " (c+3) "

This did not work... obviously, but I am very new to VBA and the syntax, so any help is appreciated. Here is the function for shtname as well:

    Function shtname() As String
    shtname = ActiveSheet.Name
    End Function
3
  • try ActiveChart.SeriesCollection(1).XValues = "='" & shtname & "'!$B$" & (c+3) & ":$N$" & (c+3) Commented Jun 3, 2016 at 18:33
  • @MutjayLee it is a row number Commented Jun 3, 2016 at 18:34
  • @MutjayLee worked like a charm, submit it as an answer and I will accept it Commented Jun 3, 2016 at 18:51

1 Answer 1

1

Even variable, if it's between "" then it becomes string.


for example let's say your shtname is "Sheet1"

On your last try line

ActiveChart.SeriesCollection(1).XValues = "='" & shtname & "'" & "!$B$" & " (c+3):$N$" & " (c+3) "

Basically, you are setting XValues as

='Sheet1'!$B$(c+3):$n$(c+3)

Try

ActiveChart.SeriesCollection(1).XValues = "='" & shtname & "'!$B$" & (c+3) & ":$N$" & (c+3)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.