Consulting

Results 1 to 4 of 4

Thread: Make seperate columns range formula refer to cell in vba?

  1. #1

    Make seperate columns range formula refer to cell in vba?

    Hi!

    I have this code:

    'ActiveChart.SetSourceData Source:=shtHis.Range("A1:A1238,D11238")

    I would like the "1238" not to refer to a cell instead, is this possible? it's important that the two columns are "seperate" i.e. that column a, b, c and d aren't selected but only column a and d?
    The cell value could fx be "100" and then the graph data would only display the shtHis.Range("A1:A100,D1100")

    Can anybody help me with this?

    Cheers

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Something like this:
    Dim lRow as Long
    lRow = sheets("some sheet").Range("A1").value
    ActiveChart.SetSourceData Source:=shtHis.Range("A1:A" & lRow & ",D1:D" & lRow)
    Be as you wish to seem

  3. #3
    Worked!!! Thank you Aflatoon!

  4. #4
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    You're welcome.
    Be as you wish to seem

Posting Permissions

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