473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Excel Search and remove text by formatting.

TheSmileyCoder
2,322 Expert Mod 2GB
I have an excel sheet, in which text has been formatted, and the format has a "meaning". For example text formatted as "Strike-through" means the text is deleted.

I now need to import this into Access 2003, and I need the values in Access to not include the text marked as deleted.

Therefore I would like to do a search and replace in Excel to remove all text marked with strikethrough. Any idea how to accomplish this?

Each cell can have multiple different formats, just to compliace things. Unlike Access where each cell can only have 1 format.
With love, TheSmileyOne
May 3 '10 #1

✓ answered by TheSmileyCoder

I found out there is a property called Charecter which can be used on Range.

Expand|Select|Wrap|Line Numbers
  1. Public Sub DeleteStriked(myRange as Range)
  2.   Dim intI as Integer
  3.   Dim strNew as string
  4.   for intI=1 to len(myRange)
  5.     if myRange.Charecters(intI,1).font.Strikethrough then
  6.       'We dont want this text
  7.     Else
  8.       'We do want this text
  9.      strNew=strNew & myRange.Charecters(intI,1)
  10.     End if
  11.   next
  12. End Sub
I can now use this function to remove the striked out text. Thank you for your help, both Jim who posted, and all those who took the time to look at this.

4 4572
Jim Doherty
897 Expert 512MB
@TheSmileyOne
Quick and dirty ...set your own sheet name and ranges if it helps you :)

Expand|Select|Wrap|Line Numbers
  1. Function BlitzStrikeThrough(strfile As String)
  2.     Dim xlApp As Object, xlWB As Object, IStartedXL As Boolean
  3.     On Error Resume Next
  4.     Set xlApp = GetObject(, "excel.application")
  5.     On Error GoTo here
  6.     If xlApp Is Nothing Then
  7.         Set xlApp = CreateObject("excel.application")
  8.         IStartedXL = True
  9.         End If
  10.     Set xlWB = xlApp.Workbooks.Open(strfile)
  11.     With xlApp.Worksheets("Sheet1")
  12.         .Range("A1:H100").Select
  13.         With Selection.Font
  14.         .Strikethrough = False
  15.         End With
  16.         .Range("A1").Select
  17.     End With
  18. here:
  19.     xlWB.Close True
  20.     If IStartedXL Then xlApp.Quit
  21.     Set xlWB = Nothing
  22.     Set xlApp = Nothing
  23. End Function
May 3 '10 #2
TheSmileyCoder
2,322 Expert Mod 2GB
Thanks for your effort Jim, but thats not quite what I need. I don't need to remove the formatting, I need to remove the text parts that has a specific format. I.e. If its formatted as strikethrough, I need to delete that part of the text, without deleting the entire cell.

Basicly for each charecter in the cell, I need to check if its StrikeThrough, and if so, delete it. (Not the cell, the specific charecter.
May 3 '10 #3
TheSmileyCoder
2,322 Expert Mod 2GB
I found out there is a property called Charecter which can be used on Range.

Expand|Select|Wrap|Line Numbers
  1. Public Sub DeleteStriked(myRange as Range)
  2.   Dim intI as Integer
  3.   Dim strNew as string
  4.   for intI=1 to len(myRange)
  5.     if myRange.Charecters(intI,1).font.Strikethrough then
  6.       'We dont want this text
  7.     Else
  8.       'We do want this text
  9.      strNew=strNew & myRange.Charecters(intI,1)
  10.     End if
  11.   next
  12. End Sub
I can now use this function to remove the striked out text. Thank you for your help, both Jim who posted, and all those who took the time to look at this.
May 3 '10 #4
Jim Doherty
897 Expert 512MB
@TheSmileyOne
Elegant solution :) I obviously misunderstood your original..... apologies
May 3 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the...
1
by: Pete from Boston | last post by:
I'm going through some "learning by doing" of javascript through trial and error, and admittedly have a lot to learn. But in taking various scripts and dissecting them, I still can't figure out if...
1
by: mr_ocp | last post by:
Hi friends I need routines to create an excel file with worksheets for each customer and a text file as well for each customer, first worksheet would be a "Summary Report", here is the code that...
6
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the...
2
by: bienwell | last post by:
Hi all, Do you have any source code to import data from Excel file or text file into database in ASP.NET program ? Please give me your reference if you have. Thanks in advance
0
by: vijay mathews | last post by:
hi i am developing a chat application tool for a company i have a problem..... i have written codings for text formatting such as color, size etc in vb.net..... but when it is connected to a...
2
by: Harry Haller | last post by:
Can I remove text from a StringWriter ? I have a StringWriter object, the content of which looks like this: "<div>Some other html which I wish to keep</div>" Can I remove the unwanted <div>,...
3
by: minhtran | last post by:
Hi all Anyone has any idea how to get a Excel header column in VB.NET. Please, help me. Thank you so much in advance
3
by: =?Utf-8?B?b24tbGluZSBqb3VybmFsIGVkaXRvcg==?= | last post by:
I can't seem to cut-and-paste text, with either .doc or .html formatting, into my .asp web-pages --all the formatting is lost. Is there some code that needs to be added to the page that will...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.