473,508 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("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)

Jul 17 '05 #1
0 4552

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
28411
by: zxo102 | last post by:
Hi there, I need your help for python <--> excel. I want to paste selected cells (range) to different location on the same sheet in Excel through python. I have tried it for a while but could not...
2
3037
by: deko | last post by:
I use a complied query to export to Excel like this: SELECT * INTO . FROM tblExcelData; But I have a situation where I need to export several tables into the same worksheet. The idea is to...
4
8422
by: IMS.Rushikesh | last post by:
Hi All, I am trying to execute below code but it gives me an COMException ///// Code Start //// public string GetName(Excel.Range range) { try { if (range.Name != null)
1
1065
by: Frustrated_User_in_West_Virginia | last post by:
I wrote a Macro to sort a range. The rows in the range change from day to day. I can define the "boundrys" of the range by two variables x and z. I am declaring these as variant I define x =...
2
24447
by: George | last post by:
Is there a fast way to transfer an Excel range to an array? Example: Excel range is E2:E300 Dim person() as string Thanks, George
3
8877
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
2
1545
by: pietlinden | last post by:
I've been given the task of building a database for a manufacturer's representative. He basically imports product and resells it. He currently has this spreadsheet that's fairly complex. (Either...
0
7249
by: shantanu | last post by:
I am trying to convert a macro code to c# that will copy the values of a column and paste to anather through paste special. Everything is working fine but the transpose meathod to paste the column...
0
3501
by: drfish | last post by:
Hi, I'm a complete novice when it comes to VB so need some help. I would like a macro that performs linear regression for different cell ranges each time it is run, depending on the number of...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.