Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search for a word in excel string
#1
Not Solved
Hi,

I am trying to find the word "qtp" if exist delete it from the cell. i dont want to delete all the data from the cell . only qtp.

that means if cell has "i like qtp". i want to delete "qtp"

This code works just fine to find qtp. i dont know how to delete qtp after if finds it.

Please advise.

Code:
Dim xl
t = "qtp"
Set xl = createobject("excel.application")
xl.Visible = true
Set sd = xl.Workbooks.Open ("F:\usp\FP Tickets to Automate2.xls")
Set st = sd.Worksheets("Sheet1")
rows = st.usedrange.rows.count
coloumn = st.usedrange.columns.count
msgbox t
For i = 1 to rows
For j = 1 to 2
Dim a
a = st.cells(i,j)
msgbox "a  "   &a
If Instr(1,a,t) >0 Then
'st.cells(i,6) = "pass"
msgbox "dd"
End If
Next
next
Reply
#2
Not Solved
Code used is not optimized..its time consuming. you should better be using excel find and replace option for this.

use replace function instead of delete.

First find the text "i like qtp" and then replace it with "i like".

No delete is required. Smile

Regards,
Ankesh
Reply
#3
Not Solved
I am not sure how to do that in qtp. How do i replace "i like qtp" with "i like" in excel using qtp?
Reply
#4
Not Solved
Sample Code :-
Code:
a = "i like QTP"

b= Replace(a,"QTP","")

Msgbox b
Reply
#5
Not Solved
First i need to find out whether QTP exist. if exist then replace with blank space. How to do that in excel?

I am simply working with excel. I just need to delete any cell has qtp and delete that. That cell has lot of data along with qtp.

How?

First i want to find whether any cell has qtp with other data.
second if qtp exist, replace with blank or delete it.

(11-21-2012, 07:08 PM)ssvali Wrote: Sample Code :-
Code:
a = "i like QTP"

b= Replace(a,"QTP","")

Msgbox b

In excel, i also have in different cells 2) 3) 4).
I want to delete all of them (2) 3) 4).
) if it is any cell.
Reply
#6
Not Solved
Can you please attach ur excel...
Reply
#7
Not Solved
Code:
Dim appExcel, objWorkBook, objSheet, columncount, rowcount,

'Create the application object for excel
Set appExcel = CreateObject("Excel.Application")

'Set the workbook object by opening
Set objWorkBook = appExcel.Workbooks.open("c:\Smoke_Test\SmokeTest.xls")

'Set the Worksheet object
Set objSheet = appExcel.Sheets("Global")

'Get the count for total used columns
columncount = objSheet.usedrange.columns.count

'Get the count for total used rows
rowcount = objSheet.usedrange.rows.count

'Assign the data to search for
Find_Details="Report"

'Iterate the loop through each cell to find out required data
For a= 1 to rowcount
For b = 1 to columncount
fieldvalue =objSheet.cells(a,b)
If  cstr(fieldvalue)= Cstr(Find_Details) Then
msgbox cstr(fieldvalue)
Exit For
End If
Next
Next
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CyberArk CorePAS REST API to search for accounts pramod 0 544 06-29-2023, 03:11 PM
Last Post: pramod
  UFT Word automation wannel 1 2,147 10-31-2016, 06:59 PM
Last Post: wannel
  VB Script to separate upper & small Letters from a string and store in excel pradeep537 1 2,074 08-05-2016, 12:26 AM
Last Post: Ankur
  Search All Test scripts For a Function? AndyBSG 1 2,576 02-19-2015, 04:15 AM
Last Post: supputuri
  Replace a string in a word document with another string rekha.naik 8 15,005 11-14-2013, 12:58 PM
Last Post: pranikgarg

Forum Jump:


Users browsing this thread: 1 Guest(s)