Cell Range
Cell Range
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Cell Range

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I'm currently using this code to find my starting row for a range, how can I declare this as my starting row?

    thanks

    Matt

    Cells.Find(What:="CURRENT MONTH TO DATE TOTALS", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=True).Activate

  2. #2
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Matt

    Just use:

    Dim rStartRange As Range
    Set rStartRange = Cells.Find(What:="CURRENT MONTH TO DATE TOTALS", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=True)

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Dave

    I've tried to use the rStartRange as part of a macro for producing a chart but it is falling down on the "Set rStartRange" line. Can you spot why it is falling down, error messsage is Method 'Cells' of Object '_Global' failed

    Sub SSChart()

    Dim Cht As Chart
    Dim Lastrow As Long
    Dim CurrentSheet As String
    Dim rStartRange As Range

    Set rStartRange = Cells.Find(What:="CURRENT MONTH TO DATE TOTALS", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=True)


    CurrentSheet = ActiveSheet.Name


    Set Cht = Application.Charts.Add
    Lastrow = Sheets(CurrentSheet).Range("A100").End(xlUp).Row


    With Cht
    .ChartType = xlXYScatter
    .SetSourceData Source:=Sheets(CurrentSheet).Range("A" & rStartRange & ":A" & Lastrow & ",D" & rStartRange & ":D" & Lastrow), PlotBy:=xlColumns
    .SeriesCollection(1).XValues = Worksheets(CurrentSheet).Range("A" & rStartRange & ":A" & Lastrow)
    .SeriesCollection(1).Values = Worksheets(CurrentSheet).Range("D" & rStartRange & ":D" & Lastrow)
    .Location Where:=xlLocationAsObject, Name:=CurrentSheet
    End With

    End Sub

  4. #4
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    How are you running the macro, if via a CommandButton from the Control toolbox set it's "TakeFocus*******" property to false. Or better still use a CommandButton from the Forma toolbar.


User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com