2

VBA Deleting words after string

 2 years ago
source link: https://www.codesd.com/item/vba-deleting-words-after-string.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

VBA Deleting words after string

advertisements

I am trying to delete all words after the first occurrence of an open parentheses in all cells starting from cell D14. I keep coming up with a Object Required error, and not sure where the issue lies.

Dim startRow As Integer
Dim pos_of_parenth As Integer
Dim resultString as String

startRow = 15

With Windows(NewTemplateName)
    .Activate
    .ActiveSheet.Range("D" & startRow).Select
    Do While .ActiveSheet.Range("D" & startRow).Value <> ""
        resultString = ""
        pos_of_parenth = InStr(1, ActiveSheet.Range("D" & startRow).Text, "(", CompareMethod.Text)
        resultString = Left(.ActiveSheet.Range("D" & startRow).Value, pos_of_parenth)
        startRow = startRow + 1
    Loop
End With


Change CompareMethod.Text to VbCompareMethod.vbTextCompare

Related Articles

Delete words after a particular word in a long string

As i want to extract a portion from a string, i use the following code c_name = Str.Substring(Str.IndexOf("Name ") + 5) But it eliminate the portion which i want. is their any possibility t select words up to certain word/Remove words after a pa

Deleting words after a specific character

I'm using a software to edit songs using regular expressions. This is what I have: Jimmy Eat World - The Middle (.mp3) What I would like to do is delete the space before the "-" and everything after, so I would just be left with "Jimmy Eat

Check if there is a word after a word (NSSTRING)

I have a fun little tricky problem. So I need to create an if statement that can detect if there is a word after a word in an array so my code is NSArray *words = [texfield.text componentsSeparatedByString:@" "]; int index = [words indexOfObject

T-SQL - Divide the following word after two specific words

Imagine that I have the following String: "Select * From table_1 INNER JOIN table_2 ON table_1.A = table_2.B" I want to extract the two tables of the statement in order to get: table_1 ; table_2. Basically I need to get the next word after strin

Delete all after a certain word in a SQL string

I have found statements that delete everything after a certain character. How do i delete everything after a word even though the length after that word may vary. 11000 PLACIDA RD BLDG 15 UNIT 1504 17200 ACAPULCO RD BLDG 1 I want to delete everything

Have a string to replace all words after x with y

Having string, how can I replace all words, special characters, numbers, what ever is next after x with y. Example: Input: String test = "Hello @\"Thomas Anderson\" how are you? Today is 06/13/2013 com month day year !! \"example of da

Delete the word after or around the cursor in VIM

I'm now switching to VIM from TextMate. I found ^+W in insert mode very useful. However, I'd like to delete not only the word before cursor, but the word after or around cursor as well. I did some googling, but the only thing i can found was that ^+W

Get the word after a particular word in a Ruby string?

How do I get the word after a particular word in a Ruby string? For example: From:Ysxrb<[email protected]>\nTo: <[email protected]>Subject: xyzabc\nDate: Tue, 19 Jun 2012 03:26:56 -0700\nMessage-ID: <9D.A1.02635.ABB40EF4@ecout1> I just want to

how to find a word in a file that matches the html entry, and then delete the entire string

This question already has an answer here: How to Remove Some Line from Text File Using PHP? 2 answers `<?php $aclname = $_POST['aclname']; $file = file_get_contents("test.txt"); $lines = explode("\n", $file); $exclude = array(); for

Regex in PHP: take all the words after the first string and truncate all the first character

I'm quite terrible at regexes. I have a string that may have 1 or more words in it (generally 2 or 3), usually a person name, for example: $str1 = 'John Smith'; $str2 = 'John Doe'; $str3 = 'David X. Cohen'; $str4 = 'Kim Jong Un'; $str5 = 'Bob'; I'd l

Deleting words from a string applescript

I have a string "remind me to eat dinner at 5:30" I need to remove every word before "to" and every word after "at" I already wrote a script to get the word number of them toNum and atNum I can't figure out how to do this any

Find the next word after a word in a string

I am trying to record the word after a specific word. For example, let's say I have a string: First Name: John Last Name: Doe Email: [email protected] I want to search the string for a key word such as "First Name:". Then I want to only capture

Find a word after a specific string - sql management studio 2012

I have a text column with fields as per below (small sample, there are many variations): INSERT INTO #retention1 VALUES ('hello Action=Refer non-action=non-refer') INSERT INTO #retention1 VALUES ('bye Action=Follow non-action=non-refer') INSERT INTO

Delete words from the string by not modifying the other name that contains this word

CompanyName Desired Output Abbey Company.Com abbey company Manisd Company .com manisd company Idely.com idely How can i remove .com,while taking care that "com" from company is not effected. I've tried the below code stopwords = c("limited&

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK