4D Blog

Home Product Code a range in 4D View Pro

Code a range in 4D View Pro

January 28, 2019

Product

4D v17 R4 brings new features to 4D View Pro and one of them is the creation of ranges with code.

First, you need to define a range object to manipulate your cells by programming. You can do this in 4D View Pro with the following new commands: VP Cell, VP Cells, VP Column, VP Row, VP All and VP Combine ranges.

A range object can define:

  • a cell or a group of cells,
  • a column or a group of columns,
  • a row or a group of rows
  • all the cells of a sheet.

define a cell or a group of cells

To define coordinates of a single cell, use the VP Cell command:

$column:=3 //column of beginning cell
$row:=5 //row of beginning cell
$sheet:=2 // specific workbook sheet
$cellObj1:=VP Cell ("ViewProArea";$column;$row) // cell D6 (current sheet)
$cellObj2:=VP Cell ("ViewProArea";$column;$row;$sheet) // cell D6 sheet 3

   Keep in mind that the row index, the column index, and the sheet index start at 0. So the coordinates of the first upper left cell is (0;0)!

A group of cells is basically defined by referencing the upper left cell and the count of rows and cells. Pass this information to the VP Cells command:

$column:=3 //column of beginning cell
$row:=5 //row of beginning cell
$columnCount:=2 // total number of columns
$rowCount:=3 // total number of rows
$sheet:=2 // specific workbook sheet
$cellsObj1:=VP Cells ("ViewProArea";$column;$row;$columnCount;$rowCount) // cells D6 to E8 (current sheet)
$cellsObj2:=VP Cells ("ViewProArea";$column;$row;$columnCount;$rowCount;$sheet) // cells D6 to E8 on sheet 3

define a column or a group of columns

To define a column’s coordinate, pass the column index to the VP Column command. If you need to define several contiguous columns, add a column count after the column index:

$column:=3 // beginning column
$columnCount:=2 // total number of columns
$sheet:=2 // specific workbook sheet
$colObj1:=VP Column ("ViewProArea";$column) // column D (current sheet)
$colObj2:=VP Column ("ViewProArea";$column;$columnCount) // column D + column E (current sheet)
$colObj3:=VP Column ("ViewProArea";$column;$columnCount;$sheet) // column D + column E sheet 3

define a row or a group of rows

To define a row’s coordinates, pass the column index to the command VP Row. If you need to define several contiguous rows, add a row count after the row index:

$row:=5 // beginning row
$rowCount:=3 // total number of rows
$sheet:=2 // specific workbook sheet
$rowObj1:=VP Row ("ViewProArea";$row) // row 6
$rowObj2:=VP Row ("ViewProArea";$row;$rowCount) // row 6 + row 7 + row 8
$rowObj3:=VP Row ("ViewProArea";$row;$rowCount;$sheet) // row 6 + row 7 + row 8 sheet 2

define an irregular cell range

An irregular cell range is when you need to combine several, separate (discontinuous) groups of cells within the same range. To do so, create an individual range for each continuous group, then pass them all in parameter to the VP Combine ranges command:

$combine:=VP Combine ranges ($cellObj1;$colObj1;$rowObj1;rowObj2;cellsObj2)

Discuss

Tags 4D View Pro, Spreadsheet, v17 R4, v18

Latest related posts

  • April 29, 2025

    Discover your AI-powered writing assistant in 4D Write Pro

  • April 28, 2025

    Unlock the Power of AI with 4D AIKit: Automate, Create, and Innovate

  • April 25, 2025

    Formulas in Label Wizard

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy