Selecting a flexible range in Excel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Punky

    #1

    Selecting a flexible range in Excel

    Hi all,

    I've gotten a long way with my application, but now it's generating an error
    to which I know no response. I hope any of you can (and will) help me. Below
    is the code. It's a simple piece of code which should select a flexible
    range (one column wide) on one worksheet and copy it to another. Where
    things go wrong is in the last part of the code, for some reason the range
    is not selected properly. I've tried adding quotation marks to it, but that
    generates an error upon leaving the line. How do I get the proper selection
    for copying?
    Thanks in advance,
    Punky

    Public Sub StandOpmaken()
    Dim stLaatsteRace As String
    Dim iDeelnemers As Integer
    Dim iBereik As Integer
    Dim stUitslag As String
    Dim stPunten As String

    Worksheets("Dee lnemers").Activ ate
    iDeelnemers = ActiveSheet.Ran ge("K1").Value
    iBereik = 3 + iDeelnemers 'returns 12, which is OK
    stUitslag = ("A4, A" & iBereik) ' returns A4, A12, which it should
    stPunten = ("M4, M" & iBereik) 'teturns M4,M12 as expected

    ' totaalstand kopiƫren
    ActiveSheet.Ran ge(stUitslag).C opy _
    Destination:=Wo rksheets("Stand ").Range("a 1")
    ActiveSheet.Ran ge(stPunten).Co py _
    Destination:=Wo rksheets("Stand ").Range("b 1")
    Worksheets("Sta nd").Range("uit slag").Sort _
    key1:=Worksheet s("Stand").Colu mns("B"), _
    order1:=xlDesce nding, _
    header:=xlYes

    --
    Punky

    Leven is leven dat leven wil te midden van leven dat leven wil (dr. A.
    Schweitzer)



Working...