Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to select a variable range of rows in a worksheet ?
Message
From
25/02/2010 07:16:00
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
25/02/2010 03:51:50
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01450925
Message ID:
01450930
Views:
38
>Hi,
>I want to set a formula to Column D2 to lnLastRow .
>lnLastRow is no. of rows in the worksheet, how to select the variable range of rows using the .Range method ?
>
>Please advise,
>Derek
>
>
>oExcel = CREATEOBJECT([Excel.Application])
>oWorkbook = oExcel.Workbooks.open("C:\WTS\MID\WTS77XLS.XLS")
>oExcel.Visible = .t.
>oExcel.activesheet.Range("A1").value = "Col. 1"
>oExcel.activesheet.Range("B1").value = "Col. 2"
>oExcel.activesheet.Range("C1").value = "Col. 3"
>oExcel.activesheet.Range("D1").value = "Col. 4"
>oExcel.activesheet.Range("E1").value = "Col. 5"
>
>lnLastRow = oExcel.activesheet.UsedRange.Rows.Count
>
>oExcel.activesheet.Range("D2:lnLastRow").value='=B2+C2'
>
>
You could do it:
oExcel.activesheet.Range("D2:D"+ltrim(str(m.lnLastRow))).value
with oExcel.activesheet
 .Range( .Cells( 2, 4), .Cells( m.lnLastRow, 4) ).value = '=B2+C2'
endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform