Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8517399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:41:25+00:00 2026-06-11T05:41:25+00:00

Hello I have written code for generating graph using vba. everything working correctly ,but

  • 0

Hello I have written code for generating graph using vba. everything working correctly ,but problem is i want to use variable for selecting particular column
the code is :

Set x = Range("$CF$2", Range("$CF$2").End(xlDown))
Set y = Range("$CG$2", Range("$CG$2").End(xlDown))
Dim c As Chart
Set c = ActiveWorkbook.Charts.Add
Set c = c.Location(Where:=xlLocationAsObject, Name:=assume)
With c
.ChartType = xlXYScatterLines

' set other chart properties

With .Parent
.Top = Range("cl1").Top
.Left = Range("cl12").Left
.Name = "c"
End With
End With

Dim s As Series
Set s = c.SeriesCollection(1)
With s
.Values = y
 .XValues = x
' set other series properties

End With

I want to use variable COLs in first to line they are

Set x = Range("$CF$2", Range("$CF$2").End(xlDown))
Set y = Range("$CG$2", Range("$CG$2").End(xlDown))

COLs is variable of string

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:41:27+00:00Added an answer on June 11, 2026 at 5:41 am

    I’m not sure I understand, but if you want a Range object based on a string, why not try this:

    Option Explicit
    
    Sub TestRange()
    
        '***** Declare variables
        Dim oX As Range
        Dim sCOLs As String
    
        '***** Select column
        sCOLs = "A"
    
    
        '***** Set Range based on column from sCOLs
        Set oX = Range(sCOLs & "2", Range(sCOLs & "2").End(xlDown))
    
        '***** Do something with oX
        Debug.Print TypeName(oX)
    
        '***** Clean up
        Set oX = Nothing
    
    End Sub
    

    You could also try and have the whole range as a string, maybe a bit cleaner code?

    Dim sRange as String
    
    sRange = "A2"
    
    Set oX = Range(sRange, Range(sRange).End(xlDown))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a small program just like hello the world , everything was
hello i have just start using Raphael but i'm very confused in the following
i have the next code written in C#....it create a tex file using utf-8.....the
Hello there i have written some code in jquery to add new input type
I am a beginner in Python and I have written this simple code but
I have written some code and used a string that I concatentated using the
Im using Ubuntu 10.10, Code::Blocks with GCC 4.2. I have written a code like
Hello I have written the following code. My objective was to write a function
I have written code to swap strings, but I am not able to swap.
Hello guys I have this weird problem with Razor Syntax. I have written the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.