+ Reply to Thread
Results 1 to 3 of 3

Using replace worksheet formula in vba

Hybrid View

  1. #1
    Registered User
    Join Date
    06-14-2013
    Location
    CA, USA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Using replace worksheet formula in vba

    Hello All,

    I'd like to write a macro that will go through column "CC" or 81 of Sheet1, which might either say "Name: 20 Item (Type)" or be blank.

    Then it will take the corresponding cell and put "Name" into column "I" of Sheet 2, and "Type" into column "J" of Sheet 2.

    I have an idea using a for loop and a worksheet function, but it doesn't seem to work at all.

    For i = 2 To lrow
        Cells(i, 10) = "=REPLACE(LEFT((I" & i & "),FIND("")"",(I" & i & "))-1),1,FIND(""("",(I" & i & ")),"")"
        Cells(i, 13) = "=REPLACE(LEFT((I" & i & "),FIND(""("",(I" & i & "))-1),1,FIND(""65"",(I" & i & "))+2,"")"
    Next i
    Thanks in advance!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Using replace worksheet formula in vba

    Try this.
        Range("J2:J" & Lrow).Formula = "=REPLACE(LEFT(I2,FIND("")"",I2)-1),1,FIND(""("",I2),"""")"
        Range("M2:M" & Lrow).Formula = "=REPLACE(LEFT(I2,FIND(""("",I2)-1),1,FIND(""65"",I2)+2,"""")"
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-14-2013
    Location
    CA, USA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Using replace worksheet formula in vba

    Thank you so much! This worked perfectly!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find and Replace Text in Formula on a given worksheet in an excel workbook using VBA
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2012, 08:32 PM
  2. Find and replace worksheet reference in formula
    By FM1 in forum Excel General
    Replies: 1
    Last Post: 10-16-2009, 10:38 AM
  3. Replace worksheet when importing worksheet
    By packe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-16-2007, 06:27 AM
  4. Replies: 1
    Last Post: 02-10-2005, 07:06 PM
  5. [SOLVED] How do I replace a worksheet with another worksheet in excel
    By Ammnon in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-12-2005, 07:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1