4D Blog

Home Product 4D View Pro: Find and replace with code

4D View Pro: Find and replace with code

January 25, 2021

Product

Sometimes when you initialize a 4D View Pro document, you need to find some values or tags in it and replace them with data issued from 4D. Now it’s a breeze with the VP Find command. Thanks to this command, you can find data, a formula, or a tag and replace it in the entire sheet or only a specific part of it!

Let’s find out how.

HDI VP Find

The VP Find command lets you search for a text value within a designated range in a 4D View Pro document’s text, formulas, or tags.

For example, if you want to perform a case-sensitive search for the first occurrence of the word “Total” in the text of the cells:

$range:=VP All("ViewProArea")
// find the first cell that contains the word 'Total' in the current sheet
$result:=VP Find($range; "Total")
// Make the cell background yellow for the found cells
VP SET CELL STYLE($result; New object("backColor"; "yellow"))

Now you can refine your search to find all of the cells containing “Total” by using the all property:

$range:=VP All("ViewProArea")
$condition:=New object
// Search in all values in the range
$condition.all:=True
// Find all cells containing the word 'Total' in the current sheet
$result:=VP Find($range; "Total"; $condition)
// Make the cell background yellow for the found cells
VP SET CELL STYLE($result; New object("backColor"; "yellow"))

blank

  • If you want to perform a search for “Total” without taking the case into account, just modify the flags property:

$range:=VP All("ViewProArea")
$condition:=New object
// Search the entire sheet
$condition.all:=True
// Search cells containing the word "Total" without considering the case 
$condition.flags:=vk find flag ignore case
// Find all cells containing only the word 'Total' in the current sheet
$result:=VP Find($range; "Total"; $condition)
// Make the cell background yellow for the found cells
VP SET CELL STYLE($result; New object("backColor"; "yellow"))

blank

  • If you want to replace all of the found “Total” words with “4D”, add a parameter with the replacement text:

$range:=VP All("ViewProArea")
$condition:=New object
// Search the entire sheet
$condition.all:=True
// Search cells containing the word "Total" without considering the case
$condition.flags:=vk find flag ignore case
// Replace text in all cells containing only 'Total' with "4D"
$result:=VP Find($range; "Total"; $condition;"4D")
// Make the cell background yellow for the found cells
VP SET CELL STYLE($result; New object("backColor"; "yellow"))

blank

Of course, these are just a few of the possibilities enabled by the VP Find command.

Find out more in the doc center to learn more, like how to find values with wild cards, search in formulas, and much more.

Discuss

Tags 4D View Pro, Find, Programming, Spreadsheet, v18 R6, v19

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

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