Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:24:24+00:00 2026-06-13T17:24:24+00:00

I have a excel template, where we have different predefined fields like CustomerName, CompanyName,

  • 0

I have a excel template, where we have different predefined fields like CustomerName, CompanyName, Address etc. All this things are in single cell and this cell is named as “Customer” and similarly we have another cell called “Sender” having fields related to sender details. My job is to find Customer and Sender cells and replace the values that they contain with the actual values, For example i need to find “Customer” Cell and will replace CustomerName with actual name “John”, ComanyName with “XYZ” and so on for other fields, same task is for Sender Cell.

I am using Microsoft.Office.Interop.Excel to implement this task as follows.

xlWorkSheet.Cells.Replace(“CustomerName”, “John”, Excel.XlLookAt.xlPart, missingValue, missingValue, missingValue, missingValue, missingValue);

xlWorkSheet.Cells.Replace(“CompanyName”, “XYZ”, Excel.XlLookAt.xlPart, missingValue, missingValue, missingValue, missingValue, missingValue);

The problem is all this fields in a single cell, and i need to find different fields and replace their values, if a fields values is not then shifting the remaining fields up to fill the empty space.

Please provide solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:24:25+00:00Added an answer on June 13, 2026 at 5:24 pm

    I would pull the data into a string, do the string manipulation and then set it back to the cell value…

    Dim StrToReplace as string = xlWorkSheet.Range("Customer").value
    
    StrToReplace = StrToReplace.replace("CustomerName", "John")
    StrToReplace = StrToReplace.replace("CompanyName", "XYZ")
    ... etc
    
    xlWorkSheet.Range("Customer").value = StrToReplace
    

    You can make it even more efficient by not repeating the StrToReplace.replace on multiple lines such as:

    StrToReplace = StrToReplace.replace("CustomerName", "John").replace("CompanyName", "XYZ")
    

    Or, perhaps using a stringbuilder, but this should at least point you in the right direction to solve the current problem.

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a excel template(.xlt), and I want to do custom validation for this
Ok I have a excel template file which contains various headers, images etc. I
Hi I have a template excel which I load and would like to change
I have developed office project in 2003 (Excel template).All features are working fine but
I have an Excel workbook that I want to use as a template. It
I have an excel file (that I use as a template) with two rows.
I have an excel template that uses a macro to save the file, so
I have an Excel template that I use to create PDF specification sheets for
I have created a xlt excel template which works fine in Excel 2007 under
I have the following code to open Excel template file and save it as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.