home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,236 of 10,840   
   Punky to All   
   Selecting a flexible range in Excel   
   24 Feb 05 15:25:38   
   
   From: lindajakobs@wanadoo.nl   
      
   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("Deelnemers").Activate   
     iDeelnemers = ActiveSheet.Range("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.Range(stUitslag).Copy _   
           Destination:=Worksheets("Stand").Range("a1")   
      ActiveSheet.Range(stPunten).Copy _   
           Destination:=Worksheets("Stand").Range("b1")   
      Worksheets("Stand").Range("uitslag").Sort _   
       key1:=Worksheets("Stand").Columns("B"), _   
       order1:=xlDescending, _   
       header:=xlYes   
      
   --   
   Punky   
      
   Leven is leven dat leven wil te midden van leven dat leven wil (dr. A.   
   Schweitzer)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca